rendezvous: rename stats keys for consistency

This commit is contained in:
Brian Warner 2016-06-26 17:15:53 -07:00
parent df96f2e590
commit f950161642

View File

@ -541,15 +541,15 @@ class Rendezvous(service.MultiService):
def q(query, values=()): def q(query, values=()):
row = self._db.execute(query, values).fetchone() row = self._db.execute(query, values).fetchone()
return list(row.values())[0] return list(row.values())[0]
c["total_nameplates"] = q("SELECT COUNT() FROM `nameplates`") c["nameplates_total"] = q("SELECT COUNT() FROM `nameplates`")
# TODO: nameplates with only one side (most of them) # TODO: nameplates with only one side (most of them)
# TODO: nameplates with two sides (very fleeting) # TODO: nameplates with two sides (very fleeting)
# TODO: nameplates with three or more sides (crowded, unlikely) # TODO: nameplates with three or more sides (crowded, unlikely)
c["total_mailboxes"] = q("SELECT COUNT() FROM `mailboxes`") c["mailboxes_total"] = q("SELECT COUNT() FROM `mailboxes`")
# TODO: mailboxes with only one side (most of them) # TODO: mailboxes with only one side (most of them)
# TODO: mailboxes with two sides (somewhat fleeting, in-transit) # TODO: mailboxes with two sides (somewhat fleeting, in-transit)
# TODO: mailboxes with three or more sides (unlikely) # TODO: mailboxes with three or more sides (unlikely)
c["total_messages"] = q("SELECT COUNT() FROM `messages`") c["messages_total"] = q("SELECT COUNT() FROM `messages`")
# usage since last reboot # usage since last reboot
nameplate_counts = collections.defaultdict(int) nameplate_counts = collections.defaultdict(int)
@ -561,18 +561,18 @@ class Rendezvous(service.MultiService):
for result, count in mc.items(): for result, count in mc.items():
mailbox_counts[result] += count mailbox_counts[result] += count
urb = stats["since_reboot"] = {} urb = stats["since_reboot"] = {}
urb["nameplates"] = {} urb["nameplate_moods"] = {}
for result, count in nameplate_counts.items(): for result, count in nameplate_counts.items():
urb["nameplates"][result] = count urb["nameplate_moods"][result] = count
urb["total_nameplates"] = sum(nameplate_counts.values()) urb["nameplates_total"] = sum(nameplate_counts.values())
urb["mailboxes"] = {} urb["mailbox_moods"] = {}
for result, count in mailbox_counts.items(): for result, count in mailbox_counts.items():
urb["mailboxes"][result] = count urb["mailbox_moods"][result] = count
urb["total_mailboxes"] = sum(mailbox_counts.values()) urb["mailboxes_total"] = sum(mailbox_counts.values())
# historical usage (all-time) # historical usage (all-time)
u = stats["all_time"] = {} u = stats["all_time"] = {}
un = u["nameplates"] = {} un = u["nameplate_moods"] = {}
# TODO: there's probably a single SQL query for all this # TODO: there's probably a single SQL query for all this
un["happy"] = q("SELECT COUNT() FROM `nameplate_usage`" un["happy"] = q("SELECT COUNT() FROM `nameplate_usage`"
" WHERE `result`='happy'") " WHERE `result`='happy'")
@ -582,8 +582,8 @@ class Rendezvous(service.MultiService):
" WHERE `result`='pruney'") " WHERE `result`='pruney'")
un["crowded"] = q("SELECT COUNT() FROM `nameplate_usage`" un["crowded"] = q("SELECT COUNT() FROM `nameplate_usage`"
" WHERE `result`='crowded'") " WHERE `result`='crowded'")
u["total_nameplates"] = q("SELECT COUNT() FROM `nameplate_usage`") u["nameplates_total"] = q("SELECT COUNT() FROM `nameplate_usage`")
um = u["mailboxes"] = {} um = u["mailbox_moods"] = {}
um["happy"] = q("SELECT COUNT() FROM `mailbox_usage`" um["happy"] = q("SELECT COUNT() FROM `mailbox_usage`"
" WHERE `result`='happy'") " WHERE `result`='happy'")
um["scary"] = q("SELECT COUNT() FROM `mailbox_usage`" um["scary"] = q("SELECT COUNT() FROM `mailbox_usage`"
@ -598,8 +598,8 @@ class Rendezvous(service.MultiService):
" WHERE `result`='pruney'") " WHERE `result`='pruney'")
um["crowded"] = q("SELECT COUNT() FROM `mailbox_usage`" um["crowded"] = q("SELECT COUNT() FROM `mailbox_usage`"
" WHERE `result`='crowded'") " WHERE `result`='crowded'")
u["total_mailboxes"] = q("SELECT COUNT() FROM `mailbox_usage`") u["mailboxes_total"] = q("SELECT COUNT() FROM `mailbox_usage`")
u["standalone_mailboxes"] = q("SELECT COUNT() FROM `mailbox_usage`" u["mailboxes_standalone"] = q("SELECT COUNT() FROM `mailbox_usage`"
" WHERE `for_nameplate`=0") " WHERE `for_nameplate`=0")
# recent timings (last 100 operations) # recent timings (last 100 operations)