Skip to content

Commit

Permalink
Merge branch 'release/1.24.00'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstibbs committed Jan 8, 2015
2 parents dd1113a + 101e575 commit a4c8d70
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box = "ubuntu/trusty64"

config.vm.network "forwarded_port", guest: 5432, host: 15432
config.vm.network "forwarded_port", guest: 5432, host: 5432
config.vm.network "forwarded_port", guest: 5000, host: 15000
config.vm.network "forwarded_port", guest: 80, host:10080
config.vm.network "forwarded_port", guest: 15672, host: 15673
Expand Down
4 changes: 2 additions & 2 deletions blockbuster/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'matt'
__version__ = '1.23.05'
__db_schema_version__ = '1.23.00'
__version__ = '1.24.00'
__db_schema_version__ = '1.24.00'

from flask import Flask
app = Flask(__name__)
Expand Down
26 changes: 7 additions & 19 deletions blockbuster/bb_dbconnector_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,32 +491,20 @@ def db_stats_check(self):
datetime.date.today().day)

try:
sql = "SELECT * from stats_usage " \
sql = "SELECT date::text, instance_name, name, count from v_stats_usage " \
"where date = %s;"

data = (today,)

self.cursor.execute(sql, data)
rows = self.cursor.fetchall()
if len(rows) < 1:
return "No User Activity Today"

stats = ""
if len(rows) > 1:
i = 0
stats = "<html><body>"
for row in rows:
statrow = str(row[0]) + ", " + str(row[1]) + ", " + str(row[2] + ", " + str(row[3]))
stats = stats + statrow + "<br/>"
i += 1
stats = stats + "</body></html>"

return stats, 200
self.dict_cursor.execute(sql, data)
rows = self.dict_cursor.fetchall()
return rows

except psycopg2.DatabaseError, e:
self.log_exception(e)
log.error("Error getting stats from database.\n" + str(e))
return "500: Error retrieving stats from database", 500
empty = {}
return {}

# Take a mobile number, return a list of active blocks from that number
def get_list_of_blocks_for_blocker(self, blocker_mobile):
Expand Down Expand Up @@ -942,7 +930,7 @@ def api_blocks_getall(self):
log.debug("Getting all blocks")

try:
sql = "SELECT * from active_blocks;"
sql = "SELECT * from v_active_blocks;"
self.dict_cursor.execute(sql,)
rows = self.dict_cursor.fetchall()
return rows
Expand Down
18 changes: 11 additions & 7 deletions blockbuster/bb_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,31 @@ def decorated(*args, **kwargs):
return f(*args, **kwargs)
return decorated


# Core App Routes
@app.route("/InboundSMS/", methods=['POST'])
def post_inboundsms():
bb_auditlogger.BBAuditLoggerFactory().create().logAudit('app', 'POST_INBOUNDSMS', request.form['Body'])
return bb_request_processor.process_twilio_request(request)


@app.route("/stats/", methods=['GET'])
def get_stats():
stats = bb_api_request_processor.APIRequestProcessor().service_stats_get()
bb_auditlogger.BBAuditLoggerFactory().create().logAudit('app', 'GET_STATS', stats)
return stats


@app.route("/status/", methods=['GET'])
def get_status():
status = bb_api_request_processor.APIRequestProcessor().service_status_get()
bb_auditlogger.BBAuditLoggerFactory().create().logAudit('app', 'GET_STATUS', status)
return status


# API Routes
@app.route("/api/v1.0/stats/", methods=['GET'])
@requires_auth
def get_stats():
result = bb_api_request_processor.APIRequestProcessor()\
.service_stats_get()
bb_auditlogger.BBAuditLoggerFactory().create().logAudit('app', 'GET_STATS', str(result))
return jsonify(stats=result)


@app.route("/api/v1.0/cars/", methods=['GET'])
@requires_auth
def uri_get_cars():
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# This section only applies when you are running run.py directly
if __name__ == '__main__':
blockbuster.bb_logging.logger.info("Running http on port 5000")
blockbuster.app.run(host='0.0.0.0')
blockbuster.app.run(host='0.0.0.0', debug=True)
50 changes: 50 additions & 0 deletions sql/008_1.23.00-1.24.00.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
BEGIN;

-- Rename the status_usage view to use v_XXXXXX naming convention
ALTER VIEW IF EXISTS stats_usage RENAME TO v_stats_usage;
ALTER VIEW IF EXISTS active_move_requests RENAME TO v_active_move_requests;
ALTER VIEW IF EXISTS active_blocks RENAME TO v_active_blocks;


-- Create Table: tbl_users_api
CREATE TABLE tbl_users_api
(
api_user_ref uuid NOT NULL DEFAULT uuid_generate_v4(),
username text NOT NULL,
password text NOT NULL DEFAULT 0,
enabled boolean NOT NULL DEFAULT true,
CONSTRAINT tbl_users_api_pkey PRIMARY KEY (api_user_ref),
CONSTRAINT tbl_users_api_username_key UNIQUE (username)
)
WITH (
OIDS=FALSE
);
ALTER TABLE tbl_users_api
OWNER TO blockbuster;


-- Create Index: username
CREATE INDEX username
ON tbl_users_api
USING btree
(username COLLATE pg_catalog."default");

-- Index: mobile
CREATE INDEX mobile
ON users
USING btree
(mobile COLLATE pg_catalog."default");

-- Index: registration
CREATE INDEX registration
ON registrations
USING btree
(registration COLLATE pg_catalog."default");


-- Update schema version to 1.24.00
UPDATE general
SET value = '1.24.00'
WHERE key = 'version';

COMMIT;
3 changes: 2 additions & 1 deletion sql/UpgradeDB.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
\i ./004_1.18.00-1.19.00.sql
\i ./005_1.19.00-1.20.00.sql
\i ./006_1.20.00-1.20.01.sql
\i ./007_1.20.01-1.23.00.sql
\i ./007_1.20.01-1.23.00.sql
\i ./008_1.23.00-1.24.00.sql

0 comments on commit a4c8d70

Please sign in to comment.