schema change: prep usage
table for including transit too
This commit is contained in:
parent
fb493da8c7
commit
a3656c162b
|
@ -21,14 +21,17 @@ CREATE INDEX `messages_idx` ON `messages` (`appid`, `channelid`);
|
|||
|
||||
CREATE TABLE `usage`
|
||||
(
|
||||
`type` VARCHAR, -- "rendezvous"
|
||||
`started` INTEGER, -- seconds since epoch, rounded to one day
|
||||
`result` VARCHAR, -- happy, scary, lonely, errory, pruney
|
||||
-- "happy": both sides close with mood=happy
|
||||
-- "scary": any side closes with mood=scary (bad MAC, probably wrong pw)
|
||||
-- "lonely": any side closes with mood=lonely (no response from 2nd side)
|
||||
-- "errory": any side closes with mood=errory (other errors)
|
||||
-- "pruney": channels which get pruned for inactivity
|
||||
-- "crowded": three or more sides were involved
|
||||
-- rendezvous moods:
|
||||
-- "happy": both sides close with mood=happy
|
||||
-- "scary": any side closes with mood=scary (bad MAC, probably wrong pw)
|
||||
-- "lonely": any side closes with mood=lonely (no response from 2nd side)
|
||||
-- "errory": any side closes with mood=errory (other errors)
|
||||
-- "pruney": channels which get pruned for inactivity
|
||||
-- "crowded": three or more sides were involved
|
||||
`total_bytes` INTEGER, -- not yet used
|
||||
`total_time` INTEGER, -- seconds from start to closed, or None
|
||||
`waiting_time` INTEGER -- seconds from start to 2nd side appearing, or None
|
||||
);
|
||||
|
|
|
@ -32,8 +32,9 @@ def show_usage(args):
|
|||
newest = None
|
||||
counters = defaultdict(int)
|
||||
db = get_db("relay.sqlite")
|
||||
c = db.execute("SELECT * FROM `usage` ORDER BY `started` ASC LIMIT ?",
|
||||
(args.n,))
|
||||
c = db.execute("SELECT * FROM `usage` WHERE `type`=?"
|
||||
" ORDER BY `started` ASC LIMIT ?",
|
||||
(u"rendezvous", args.n))
|
||||
for row in c.fetchall():
|
||||
counters["total"] += 1
|
||||
counters[row["result"]] += 1
|
||||
|
@ -65,8 +66,9 @@ def tail_usage(args):
|
|||
seen = set()
|
||||
while True:
|
||||
old = time.time() - 2*60*60
|
||||
c = db.execute("SELECT * FROM `usage` WHERE `started` > ?"
|
||||
" ORDER BY `started` ASC", (old,))
|
||||
c = db.execute("SELECT * FROM `usage`"
|
||||
" WHERE `type`=? AND `started` > ?"
|
||||
" ORDER BY `started` ASC", (u"rendezvous", old))
|
||||
for row in c.fetchall():
|
||||
event = (row["started"], row["result"],
|
||||
row["waiting_time"], row["total_time"])
|
||||
|
|
|
@ -298,9 +298,11 @@ class Channel:
|
|||
def _store_summary(self, summary):
|
||||
(started, result, total_time, waiting_time) = summary
|
||||
self._db.execute("INSERT INTO `usage`"
|
||||
" (`started`, `result`, `total_time`, `waiting_time`)"
|
||||
" VALUES (?,?,?,?)",
|
||||
(started, result, total_time, waiting_time))
|
||||
" (`type`, `started`, `result`,"
|
||||
" `total_time`, `waiting_time`)"
|
||||
" VALUES (?,?,?, ?,?)",
|
||||
(u"rendezvous", started, result,
|
||||
total_time, waiting_time))
|
||||
self._db.commit()
|
||||
|
||||
def _summarize(self, messages, delete_time):
|
||||
|
|
Loading…
Reference in New Issue
Block a user