Index: sitescripts/reports/utils.py |
=================================================================== |
--- a/sitescripts/reports/utils.py |
+++ b/sitescripts/reports/utils.py |
@@ -16,7 +16,7 @@ |
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
import hashlib, hmac, base64, MySQLdb, os, re, marshal, subprocess |
-from sitescripts.utils import get_config, cached, get_template, sendMail |
+from sitescripts.utils import get_config, cached, get_template, anonymizeMail, sendMail |
def getReportSubscriptions(guid): |
cursor = get_db().cursor(MySQLdb.cursors.DictCursor) |
@@ -47,6 +47,24 @@ |
yield row |
offset += len(rows) |
+def getReportsForUser(contact): |
+ count = 1000 |
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.
|
+ offset = 0 |
+ while True: |
+ cursor = get_db().cursor(MySQLdb.cursors.DictCursor) |
+ executeQuery(cursor, |
+ '''SELECT guid, type, UNIX_TIMESTAMP(ctime) AS ctime, status, site, contact, |
+ comment, hasscreenshot, knownissues |
+ FROM #PFX#reports WHERE contact = %s LIMIT %s OFFSET %s''', |
+ (contact, count, offset)) |
+ rows = cursor.fetchall() |
+ cursor.close() |
+ if len(rows) == 0: |
+ break |
+ for row in rows: |
+ yield row |
+ offset += len(rows) |
+ |
def getReport(guid): |
cursor = get_db().cursor() |
executeQuery(cursor, |
@@ -102,6 +120,13 @@ |
get_db().commit() |
reportData['guid'] = guid |
+ if contact: |
+ email = reportData['email'] |
+ email = re.sub(r' at ', r'@', email) |
+ email = re.sub(r' dot ', r'.', email) |
+ reportData['email'] = anonymizeMail(email) |
+ reportData['uid'] = contact |
+ |
file = os.path.join(get_config().get('reports', 'dataPath'), guid[0], guid[1], guid[2], guid[3], guid + '.html') |
dir = os.path.dirname(file) |
if not os.path.exists(dir): |
@@ -122,6 +147,14 @@ |
if os.path.isfile(file): |
os.remove(file) |
+def getUser(contact): |
+ cursor = get_db().cursor(MySQLdb.cursors.DictCursor) |
+ executeQuery(cursor, |
+ '''SELECT reports, positive, negative FROM #PFX#users WHERE id = %s''', |
+ (contact)) |
+ user = cursor.fetchone() |
+ return user |
+ |
@cached(3600) |
def getUserUsefulnessScore(contact): |
if contact == None: |