Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 15, 2012
oau Store statistics for sent messages, close #5 932e1fe
oau Merge remote-tracking branch 'origin/master'
Conflicts:
	core.py
	core_test.py
5e54a05
Showing with 22 additions and 0 deletions.
  1. +14 −0 core.py
  2. +8 −0 sql/smskrupp.sql
View
14 core.py
@@ -364,6 +364,19 @@ def check_webuser_login(self, username, password):
return 0, 0
+ def increment_sent_stats(self, group_id):
+ day = strftime("%Y-%m-%d %H:%M:%S", localtime())
+ c = self.cursor
+ c.execute("insert or ignore into qq_groupStatistics "+
+ "(day, groupId, cnt) "+
+ "values (?,?,0)",
+ (day, group_id))
+ c.execute("update qq_groupStatistics "+
+ "set cnt=cnt+1 "
+ "where day=? and groupId=?",
+ (day, group_id))
+ self.conn.commit()
+
class Doer:
def __init__(self, sender):
self.data = Data()
@@ -464,6 +477,7 @@ def _handle_message(self, ids, src, phone, orig_msg):
members = self.data.get_group_members(group['id'])
for member in members:
self.sender.send(member['number'], msg)
+ self.data.increment_sent_stats(group['id'])
status = 'send'
elif action['action'] in ['add', 'add_sender', 'add_admin']:
group = action['group']
View
8 sql/smskrupp.sql
@@ -31,3 +31,11 @@ CREATE TABLE qq_webUserGroups (
userId integer not null,
groupId integer not null,
unique (userId,groupId));
+
+DROP TABLE IF EXISTS qq_groupStatistics;
+CREATE TABLE qq_groupStatistics (
+id integer primary key autoincrement,
+groupId integer not null,
+day datetime not null,
+cnt integer not null,
+unique (groupId,day));

No commit comments for this range

Something went wrong with that request. Please try again.