def testStatsList(self): us = UserStats('userid', 'itemid') us.save(1,2) us.save(1,3) us.save(1,4) us.save(2,2) us.save(2,3) us.save(3,4) us.save(4,4) toplist = us.get_Top_N('userid', 3) print toplist self.assertEqual(len(toplist), 3, "toplist has not enough entries") toplist = us.get_Top_N('userid', 4) self.assertEqual(len(toplist), 4, "toplist has not enough entries") self.assertEqual(int(toplist[0][0]), 1, "") self.assertEqual(int(toplist[0][1]), 3, "")
if (SAVE_DIMENSION_LIST): dimension = 'user_ids' dL = DimensionListModel( dimension ) if(debug): print "userid:\t" + str(flattenedJson['client_id']) dL.save( dimension_id = flattenedJson['client_id'], timestamp = timestamp_sec ) """ n += 1 if ( n % cycle_count == 0 and debug2): print n if (not debug3): result = r.fetch_row(maxrows = n_maxrows) # fetch N row maximum else: result = False if (not debug3): db.close() #close the database connection replay_time = time2.time() - replay_time print "time it took: " + str(replay_time) print 'It took {0:1f} seconds per item'.format(replay_time/n) us = UserStats('userid', 'itemid') the_list = us.get_Top_N('userid', 100) print the_list pH = Plot_Helper() pH.make_plot(the_list)