comparison src/ltpdarepo/views/browse.py @ 186:8da56d2a70d6

Enormously speed up activity view.
author Daniele Nicolodi <daniele@grinta.net>
date Tue, 08 Nov 2011 12:46:54 +0100
parents c52ae3f0196f
children fbab144c296c
comparison
equal deleted inserted replaced
185:5e2d298e01ef 186:8da56d2a70d6
677 curs.execute("""CALL makeintervals(%s, %s, 1, %s)""", (begin, end, increment)) 677 curs.execute("""CALL makeintervals(%s, %s, 1, %s)""", (begin, end, increment))
678 678
679 # collect number of objects for each interval 679 # collect number of objects for each interval
680 curs.execute("""SELECT ts.begin AS date, COUNT(objmeta.obj_id) AS count 680 curs.execute("""SELECT ts.begin AS date, COUNT(objmeta.obj_id) AS count
681 FROM timeintervals AS ts 681 FROM timeintervals AS ts
682 LEFT OUTER JOIN `%s`.objmeta ON (objmeta.submitted BETWEEN ts.begin AND ts.end) 682 LEFT OUTER JOIN (SELECT obj_id, submitted FROM `%s`.objmeta
683 GROUP BY ts.begin, ts.end""" % database) 683 WHERE submitted > %%s AND submitted < %%s) AS objmeta
684 ON (objmeta.submitted BETWEEN ts.begin AND ts.end)
685 GROUP BY ts.begin, ts.end""" % database, (begin, end + dt))
684 686
685 activity = curs.fetchall() 687 activity = curs.fetchall()
686 688
687 from math import ceil, floor, log10 689 from math import ceil, floor, log10
688 nmax = max(num for day, num in activity) or 1 690 nmax = max(num for day, num in activity) or 1