def count_rrd(): """Add these counts to the rrd graph""" rrd = SystemCounts( ini.get('rrd_data').format(here=HERE), ini.get('rrd_graphs').format(here=HERE)) rrd.mark(datetime.now(), BmarkMgr.count(), BmarkMgr.count(distinct=True), TagMgr.count()) rrd.update()
def count_rrd(): """Add these counts to the rrd graph""" rrd = SystemCounts( ini.get('rrd_data').format(here=HERE), ini.get('rrd_graphs').format(here=HERE)) rrd.mark( datetime.now(), BmarkMgr.count(), BmarkMgr.count(distinct=True), TagMgr.count() ) rrd.update()
def test_unique_ct(self): """Verify that our unique count method is working""" ct = 5 common = 'testing.com' users = [] for i in range(ct): user = User() user.username = gen_random_word(10) DBSession.add(user) users.append(user) for i in range(ct - 2): b = Bmark( url=gen_random_word(12), username=users[i].username ) DBSession.add(b) # Add in our dupes c = Bmark( url=common, username=users[3].username ) DBSession.add(c) DBSession.flush() d = Bmark( url=common, username=users[4].username ) DBSession.add(d) DBSession.flush() ct = BmarkMgr.count(distinct=True) eq_(4, ct, 'We should have a total of 4: ' + str(ct))
def test_per_user(self): """We should only get a pair of results for this single user""" ct = 5 common = 'testing.com' user = User() user.username = gen_random_word(10) DBSession.add(user) usercommon = User() usercommon.username = common DBSession.add(usercommon) for i in range(ct - 2): b = Bmark(url=gen_random_word(12), username=user.username) DBSession.add(b) # add in our dupes c = Bmark( url=gen_random_word(10), username=usercommon.username, ) DBSession.add(c) DBSession.flush() d = Bmark( url=gen_random_word(10), username=usercommon.username, ) DBSession.add(d) DBSession.flush() ct = BmarkMgr.count(username=usercommon.username) eq_(2, ct, 'We should have a total of 2: ' + str(ct))
def test_unique_ct(self): """Verify that our unique count method is working""" ct = 5 common = 'testing.com' users = [] for i in range(ct): user = User() user.username = gen_random_word(10) DBSession.add(user) users.append(user) for i in range(ct - 2): b = Bmark(url=gen_random_word(12), username=users[i].username) DBSession.add(b) # Add in our dupes c = Bmark(url=common, username=users[3].username) DBSession.add(c) DBSession.flush() d = Bmark(url=common, username=users[4].username) DBSession.add(d) DBSession.flush() ct = BmarkMgr.count(distinct=True) eq_(4, ct, 'We should have a total of 4: ' + str(ct))
def test_total_ct(self): """Verify that our total count method is working""" ct = 5 user = User() user.username = gen_random_word(10) DBSession.add(user) for i in range(ct): b = Bmark(url=gen_random_word(12), username=user.username) b.hash_id = gen_random_word(3) DBSession.add(b) ct = BmarkMgr.count() eq_(5, ct, 'We should have a total of 5: ' + str(ct))
def dashboard(self): """A public dashboard of the system""" # Generate some user data and stats user_count = UserMgr.count() pending_activations = ActivationMgr.count() # Generate some bookmark data. bookmark_count = BmarkMgr.count() unique_url_count = BmarkMgr.count(distinct=True) users_with_bookmarks = BmarkMgr.count(distinct_users=True) return { 'bookmark_data': { 'count': bookmark_count, 'unique_count': unique_url_count, }, 'user_data': { 'count': user_count, 'activations': pending_activations, 'with_bookmarks': users_with_bookmarks, } }
def dashboard(request): """A public dashboard of the system """ # Generate some user data and stats user_count = UserMgr.count() pending_activations = ActivationMgr.count() # Generate some bookmark data. bookmark_count = BmarkMgr.count() unique_url_count = BmarkMgr.count(distinct=True) users_with_bookmarks = BmarkMgr.count(distinct_users=True) return { 'bookmark_data': { 'count': bookmark_count, 'unique_count': unique_url_count, }, 'user_data': { 'count': user_count, 'activations': pending_activations, 'with_bookmarks': users_with_bookmarks, } }
def test_total_ct(self): """Verify that our total count method is working""" ct = 5 user = User() user.username = gen_random_word(10) DBSession.add(user) for i in range(ct): b = Bmark( url=gen_random_word(12), username=user.username ) b.hash_id = gen_random_word(3) DBSession.add(b) ct = BmarkMgr.count() eq_(5, ct, 'We should have a total of 5: ' + str(ct))
def test_per_user(self): """We should only get a pair of results for this single user""" ct = 5 common = 'testing.com' user = User() user.username = gen_random_word(10) DBSession.add(user) usercommon = User() usercommon.username = common DBSession.add(usercommon) for i in range(ct - 2): b = Bmark( url=gen_random_word(12), username=user.username ) DBSession.add(b) # add in our dupes c = Bmark( url=gen_random_word(10), username=usercommon.username, ) DBSession.add(c) DBSession.flush() d = Bmark( url=gen_random_word(10), username=usercommon.username, ) DBSession.add(d) DBSession.flush() ct = BmarkMgr.count(username=usercommon.username) eq_(2, ct, 'We should have a total of 2: ' + str(ct))
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_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)