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