Coverage for bookie.models.stats : 56%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Generate some stats on the bookmarks in the syste
Stats we want to track
- total bookmarks per day - total # of tags in the system per day - unique...not sure
- per user - number of bookmarks they have that day
- the popularity tracking numbers...let's show most popular by clicks? not really stats
- outstanding invites - invites sent but not accepted
# do the users thing as an hourly job, but assign a letter per hour of the day # and run it that way. on hour 0 run A users, on hour 1 run B users, on hour # 23 run xzy users.
"""
"""Handle our agg stuff for the stats on bookmarks"""
def get_stat(start, end, *stats): """Fetch the records from the stats table for these guys""" qry = StatBookmark.query qry = qry.filter(StatBookmark.tstamp > start) qry = qry.filter(StatBookmark.tstamp <= end)
if stats: qry = qry.filter(StatBookmark.attrib.in_(stats))
# order things up by their date so they're grouped together qry.order_by(StatBookmark.tstamp) return qry.all()
def count_unique_bookmarks(): """Count the unique number of bookmarks in the system""" total = BmarkMgr.count(distinct=True) stat = StatBookmark(attrib=UNIQUE_CT, data=total) DBSession.add(stat)
def count_total_bookmarks(): """Count the total number of bookmarks in the system""" total = BmarkMgr.count() stat = StatBookmark(attrib=TOTAL_CT, data=total) DBSession.add(stat)
def count_total_tags(): """Count the total number of tags in the system""" total = TagMgr.count() stat = StatBookmark(attrib=TAG_CT, data=total) DBSession.add(stat)
def count_importer_depth(): """Mark how deep the importer queue is at the moment""" total = ImportQueueMgr.size() stat = StatBookmark(attrib=IMPORTER_CT, data=total) DBSession.add(stat)
"""First stats we track are the counts of things.
"""
self.attrib = kwargs.get('attrib', 'unknown') self.data = kwargs.get('data', 0) |