Skip to content

Commit

Permalink
high load
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisKolganov committed Jun 28, 2015
1 parent 402b9c6 commit 37c2c74
Show file tree
Hide file tree
Showing 335 changed files with 34,077 additions and 540 deletions.
Binary file added db.sql.zip
Binary file not shown.
25 changes: 13 additions & 12 deletions db_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,18 +643,19 @@ def thread_listPosts():
query += 'createDate {} '.format(order)
query += "limit {}".format(limit) if limit != '' else ''

elif sort == 'tree':
query = """select p2.id from posts as p join posts as p2 on p2.mpath
like CONCAT(p.mpath,'%') and p.parent is null and thread = {} and createDate between '{}' and '{}'
order by p.mpath {} {};""".format(thread, since_date, max_date, order,
"limit {}".format(limit) if limit != '' else '')
else:
query = """select p2.id from posts as p2 join
(select p.mpath, p.id from posts as p where parent is null {} ) as p
on p2.mpath like CONCAT(p.mpath,'%') and thread = {} and createDate between '{}' and '{}'
order by p.mpath {}""".format("limit {}".format(limit) if limit != '' else '',
thread, since_date, max_date, order)

#elif sort == 'tree':
# query = """select p2.id from posts as p join posts as p2 on p2.mpath
# like CONCAT(p.mpath,'%') and p.parent is null and thread = {} and createDate between '{}' and '{}'
# order by p.mpath {} {};""".format(thread, since_date, max_date, order,
# "limit {}".format(limit) if limit != '' else '')
#else:
# query = """select p2.id from posts as p2 join
# (select p.mpath, p.id from posts as p where parent is null {} ) as p
# on p2.mpath like CONCAT(p.mpath,'%') and thread = {} and createDate between '{}' and '{}'
# order by p.mpath {}""".format("limit {}".format(limit) if limit != '' else '',
# thread, since_date, max_date, order)
else:
pass
cursor.execute(query)
a = []
for i in tuple(t[0] for t in cursor.fetchall()):
Expand Down
Loading

0 comments on commit 37c2c74

Please sign in to comment.