Adds imit to leader query.

this with addition of an index should dramatically reduce query processing time and increase performance.

Next step is probably to join all queries together and parse in Python afterwards.

TODO:
Start working on rendering again
Try to scale with a hundred hastags.
This commit is contained in:
Julien Lengrand-Lambert
2013-01-31 16:27:09 +01:00
parent 5af74eb10c
commit f374382032

View File

@@ -106,7 +106,7 @@ class LeaderBoard():
The list is of max size size, but can be smaller of even empty if no The list is of max size size, but can be smaller of even empty if no
user has been detected yet. user has been detected yet.
""" """
l_query = session.query(Member).filter(Member.hashtag == hashtag).order_by(desc(Member.count)) l_query = session.query(Member).filter(Member.hashtag == hashtag).order_by(desc(Member.count)).limit(size)
leaders = l_query.all() leaders = l_query.all()
if size > 0: if size > 0:
leaders = leaders[0:size] leaders = leaders[0:size]