Skip to content

Commit

Permalink
call count
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdavis committed Jan 30, 2014
1 parent f6a7676 commit ed6c368
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from raven.contrib.flask import Sentry
from twilio import TwilioRestException

from models import aggregate_stats, log_call
from models import aggregate_stats, log_call, call_count
from utils import play_or_say
from political_data import PoliticalData

Expand Down Expand Up @@ -281,7 +281,7 @@ def demo():

@app.route('/count')
def count():
return db.session.query(Call).count()
return call_count(db)


@app.route('/stats')
Expand Down
5 changes: 5 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def log_call(db, params, campaign, request):
except:
logging.error('Failed to log call: {}'.format(kwds))

def call_count(db):
try:
return db.session.query(Call).count()
except:
return 0

def aggregate_stats(cid):
zipcodes = db.session.query(Call.zipcode, func.Count(Call.zipcode)) \
Expand Down

0 comments on commit ed6c368

Please sign in to comment.