Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/reports/utils.py

Issue 5694484511719424: Issue 1569 - Issue report digest update is inefficient (Closed)
Patch Set: Created Nov. 13, 2014, 8:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 12 matching lines...) Expand all
23 executeQuery(cursor, 23 executeQuery(cursor,
24 '''SELECT url, hasmatches FROM #PFX#sublists INNER JOIN 24 '''SELECT url, hasmatches FROM #PFX#sublists INNER JOIN
25 #PFX#subscriptions ON (#PFX#sublists.list = #PFX#subscriptions.id) 25 #PFX#subscriptions ON (#PFX#sublists.list = #PFX#subscriptions.id)
26 WHERE report = %s''', 26 WHERE report = %s''',
27 (guid)) 27 (guid))
28 rows = cursor.fetchall() 28 rows = cursor.fetchall()
29 cursor.close() 29 cursor.close()
30 return rows 30 return rows
31 31
32 def getReports(startTime): 32 def getReports(startTime):
33 count = 1000 33 count = 10000
34 offset = 0 34 offset = 0
35 while True: 35 while True:
36 cursor = get_db().cursor(MySQLdb.cursors.DictCursor) 36 cursor = get_db().cursor(MySQLdb.cursors.DictCursor)
37 executeQuery(cursor, 37 executeQuery(cursor,
38 '''SELECT guid, type, UNIX_TIMESTAMP(ctime) AS ctime, status, si te, contact, 38 '''SELECT guid, type, UNIX_TIMESTAMP(ctime) AS ctime, status, si te, contact,
39 comment, hasscreenshot, knownissues 39 comment, hasscreenshot, knownissues
40 FROM #PFX#reports WHERE ctime >= FROM_UNIXTIME(%s) LIMIT %s OFFS ET %s''', 40 FROM #PFX#reports WHERE ctime >= FROM_UNIXTIME(%s) LIMIT %s OFFS ET %s''',
41 (startTime, count, offset)) 41 (startTime, count, offset))
42 rows = cursor.fetchall() 42 rows = cursor.fetchall()
43 cursor.close() 43 cursor.close()
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 dbpasswd = get_config().get('reports', 'dbpassword') 259 dbpasswd = get_config().get('reports', 'dbpassword')
260 if os.name == 'nt': 260 if os.name == 'nt':
261 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8', named_pipe=True) 261 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8', named_pipe=True)
262 else: 262 else:
263 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8') 263 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8')
264 264
265 def executeQuery(cursor, query, args=None): 265 def executeQuery(cursor, query, args=None):
266 tablePrefix = get_config().get('reports', 'dbprefix') 266 tablePrefix = get_config().get('reports', 'dbprefix')
267 query = re.sub(r'#PFX#', tablePrefix, query) 267 query = re.sub(r'#PFX#', tablePrefix, query)
268 cursor.execute(query, args) 268 cursor.execute(query, args)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld