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

Delta Between Two Patch Sets: sitescripts/urlfixer/web/submitData.py

Issue 8483155: Added typo data collection (/submitData) (Closed)
Left Patch Set: Created Oct. 9, 2012, 1:46 p.m.
Right Patch Set: Created Oct. 9, 2012, 2:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/urlfixer/web/__init__.py ('k') | sitescripts/web.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code is subject to the terms of the Mozilla Public License 3 # This Source Code is subject to the terms of the Mozilla Public License
4 # version 2.0 (the "License"). You can obtain a copy of the License at 4 # version 2.0 (the "License"). You can obtain a copy of the License at
5 # http://mozilla.org/MPL/2.0/. 5 # http://mozilla.org/MPL/2.0/.
6 6
7 import os, MySQLdb, simplejson as json 7 import os, MySQLdb, simplejson as json
8 from urlparse import parse_qs 8 from urlparse import parse_qs
9 from sitescripts.web import url_handler 9 from sitescripts.web import url_handler
10 from sitescripts.utils import cached, get_config, setupStderr 10 from sitescripts.utils import cached, get_config, setupStderr
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 dbpasswd = get_config().get("urlfixer", "dbpassword") 56 dbpasswd = get_config().get("urlfixer", "dbpassword")
57 if os.name == "nt": 57 if os.name == "nt":
58 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, 58 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database,
59 use_unicode=True, charset="utf8", named_pipe=True) 59 use_unicode=True, charset="utf8", named_pipe=True)
60 else: 60 else:
61 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, 61 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database,
62 use_unicode=True, charset="utf8") 62 use_unicode=True, charset="utf8")
63 63
64 def _get_domain_id(db, domain): 64 def _get_domain_id(db, domain):
65 cursor = db.cursor(MySQLdb.cursors.DictCursor) 65 cursor = db.cursor(MySQLdb.cursors.DictCursor)
66 cursor.execute("SELECT id FROM domains WHERE domain=%s", (domain)) 66 cursor.execute("SELECT id FROM domains WHERE domain = %s", (domain))
67 result = cursor.fetchone() 67 result = cursor.fetchone()
68 if result == None: 68 if result == None:
69 cursor.execute("INSERT INTO domains(domain) VALUES (%s)", (domain)) 69 cursor.execute("INSERT INTO domains(domain) VALUES (%s)", (domain))
70 return db.insert_id() 70 return db.insert_id()
71 else: 71 else:
72 return result["id"] 72 return result["id"]
73 73
74 def _increment_entry(db, domain_id, status): 74 def _increment_entry(db, domain_id, status):
75 cursor = db.cursor(MySQLdb.cursors.DictCursor) 75 cursor = db.cursor(MySQLdb.cursors.DictCursor)
76 cursor.execute("INSERT INTO corrections(domain, status, curr_month, prev_month , curr_year, prev_year) VALUES (%s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE curr_month=curr_month+1, curr_year=curr_year+1", (domain_id, status, 1, 0, 1, 0) ) 76 cursor.execute("INSERT INTO corrections(domain, status, curr_month, prev_month , curr_year, prev_year) VALUES (%s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE curr_month = curr_month + 1, curr_year = curr_year + 1", (domain_id, status, 1, 0, 1, 0))
Wladimir Palant 2012/10/09 14:17:08 Style nit: spaces around binary operators
LEFTRIGHT

Powered by Google App Engine
This is Rietveld