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

Unified Diff: sitescripts/reports/utils.py

Issue 8617068: Reports - user stats update (Closed)
Patch Set: Created Oct. 18, 2012, 2:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/reports/utils.py
===================================================================
--- a/sitescripts/reports/utils.py
+++ b/sitescripts/reports/utils.py
@@ -99,6 +99,12 @@
template.stream(reportData).dump(file, encoding='utf-8')
def removeReport(guid):
+ reportData = getReport(guid)
+ if (reportData.get('email', None)):
+ utility = reportData['utility']
+ contact = getUserId(reportData['email'])
+ updateUserUtility(contact, utility)
Wladimir Palant 2012/10/18 15:45:52 So you are updating user's score only after 30 day
+
cursor = get_db().cursor()
executeQuery(cursor,
'''DELETE FROM #PFX#reports WHERE guid = %s''',
@@ -111,6 +117,20 @@
if os.path.isfile(file):
os.remove(file)
+def updateUserUtility(contact, utility):
+ if utility == 0:
+ return
+ cursor = get_db().cursor()
+ if utility > 0:
+ executeQuery(cursor,
+ '''UPDATE #PFX#users SET positive = positive + 1 WHERE id = %s''',
+ (contact))
+ else:
+ executeQuery(cursor,
+ '''UPDATE #PFX#users SET negative = negative + 1 WHERE id = %s''',
+ (contact))
+ get_db().commit()
+
def saveScreenshot(guid, screenshot):
prefix = 'data:image/png;base64,'
if not screenshot.startswith(prefix):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld