[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [gettor/master] Update stats update to add locale



commit 1f016f1f72d18e049722df70564bfd6d92e4c340
Author: hiro <hiro@xxxxxxxxxxxxxx>
Date:   Thu May 23 17:14:08 2019 +0200

    Update stats update to add locale
---
 gettor/services/email/sendmail.py | 3 ++-
 gettor/utils/db.py                | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py
index 0af0af8..82c3288 100644
--- a/gettor/services/email/sendmail.py
+++ b/gettor/services/email/sendmail.py
@@ -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(
diff --git a/gettor/utils/db.py b/gettor/utils/db.py
index 73610ed..083020d 100644
--- a/gettor/utils/db.py
+++ b/gettor/utils/db.py
@@ -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):

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits