| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2012 Eyeo GmbH | 4 # Copyright (C) 2006-2012 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 30 matching lines...) Expand all Loading... | |
| 41 (startTime, count, offset)) | 41 (startTime, count, offset)) |
| 42 rows = cursor.fetchall() | 42 rows = cursor.fetchall() |
| 43 cursor.close() | 43 cursor.close() |
| 44 if len(rows) == 0: | 44 if len(rows) == 0: |
| 45 break | 45 break |
| 46 for row in rows: | 46 for row in rows: |
| 47 yield row | 47 yield row |
| 48 offset += len(rows) | 48 offset += len(rows) |
| 49 | 49 |
| 50 def getReportsForUser(contact): | 50 def getReportsForUser(contact): |
| 51 count = 1000 | 51 cursor = get_db().cursor(MySQLdb.cursors.DictCursor) |
|
Wladimir Palant
2012/11/07 09:46:18
We don't need this complicated setup for user repo
Andrey Novikov
2012/11/07 11:39:38
Done.
| |
| 52 offset = 0 | 52 executeQuery(cursor, |
| 53 while True: | 53 '''SELECT guid, type, UNIX_TIMESTAMP(ctime) AS ctime, status, site , contact, |
| 54 cursor = get_db().cursor(MySQLdb.cursors.DictCursor) | 54 comment, hasscreenshot, knownissues |
| 55 executeQuery(cursor, | 55 FROM #PFX#reports WHERE contact = %s ORDER BY ctime DESC LIMIT 100 ''', |
| 56 '''SELECT guid, type, UNIX_TIMESTAMP(ctime) AS ctime, status, si te, contact, | 56 (contact)) |
| 57 comment, hasscreenshot, knownissues | 57 rows = cursor.fetchall() |
| 58 FROM #PFX#reports WHERE contact = %s LIMIT %s OFFSET %s''', | 58 cursor.close() |
| 59 (contact, count, offset)) | 59 return rows |
| 60 rows = cursor.fetchall() | |
| 61 cursor.close() | |
| 62 if len(rows) == 0: | |
| 63 break | |
| 64 for row in rows: | |
| 65 yield row | |
| 66 offset += len(rows) | |
| 67 | 60 |
| 68 def getReport(guid): | 61 def getReport(guid): |
| 69 cursor = get_db().cursor() | 62 cursor = get_db().cursor() |
| 70 executeQuery(cursor, | 63 executeQuery(cursor, |
| 71 '''SELECT dump FROM #PFX#reports WHERE guid = %s''', | 64 '''SELECT dump FROM #PFX#reports WHERE guid = %s''', |
| 72 (guid)) | 65 (guid)) |
| 73 report = cursor.fetchone() | 66 report = cursor.fetchone() |
| 74 if report == None: | 67 if report == None: |
| 75 return None | 68 return None |
| 76 | 69 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 dbpasswd = get_config().get('reports', 'dbpassword') | 254 dbpasswd = get_config().get('reports', 'dbpassword') |
| 262 if os.name == 'nt': | 255 if os.name == 'nt': |
| 263 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8', named_pipe=True) | 256 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8', named_pipe=True) |
| 264 else: | 257 else: |
| 265 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8') | 258 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_unicod e=True, charset='utf8') |
| 266 | 259 |
| 267 def executeQuery(cursor, query, args=None): | 260 def executeQuery(cursor, query, args=None): |
| 268 tablePrefix = get_config().get('reports', 'dbprefix') | 261 tablePrefix = get_config().get('reports', 'dbprefix') |
| 269 query = re.sub(r'#PFX#', tablePrefix, query) | 262 query = re.sub(r'#PFX#', tablePrefix, query) |
| 270 cursor.execute(query, args) | 263 cursor.execute(query, args) |
| LEFT | RIGHT |