Update stats update to add locale

This commit is contained in:
hiro 2019-05-23 17:14:08 +02:00
parent 58c45eabc5
commit 1f016f1f72
2 changed files with 6 additions and 5 deletions

View File

@ -208,7 +208,8 @@ class Sendmail(object):
)
yield self.conn.update_stats(
command="links", platform=platform, service="email"
command="links", platform=platform, language=locale,
service="email"
)
yield self.conn.update_request(

View File

@ -83,17 +83,17 @@ class SQLite3(object):
query, (hid, status, id, service, date)
).addCallback(self.query_callback).addErrback(self.query_errback)
def update_stats(self, command, service, platform=None):
def update_stats(self, command, service, platform=None, language='en'):
"""
Update statistics to the database
"""
now_str = datetime.now().strftime("%Y%m%d")
query = "REPLACE INTO stats(num_requests, platform, "\
query = "REPLACE INTO stats(num_requests, platform, language, "\
"command, service, date) VALUES(COALESCE((SELECT num_requests FROM stats "\
"WHERE date=?)+1, 0), ?, ?, ?, ?) "\
"WHERE date=?)+1, 0), ?, ?, ?, ?, ?) "\
return self.dbpool.runQuery(
query, (now_str,platform, command, service, now_str)
query, (now_str, platform, language, command, service, now_str)
).addCallback(self.query_callback).addErrback(self.query_errback)
def get_links(self, platform, language, status):