Skip to content

Commit 341846a

Browse files
add afk call time query
1 parent 93bbd58 commit 341846a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

misc/report_spent_time.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
mydb = myclient["komubot"]
99
mycol = mydb["komu_tracker_spent_time"]
1010

11+
def get_call_time(aw, email, timeperiods):
12+
query = f"""
13+
events = flood(query_bucket(find_bucket("aw-watcher-window_{email}")));
14+
afk = flood(query_bucket(find_bucket("aw-watcher-afk_{email}")));
15+
afk = filter_keyvals(afk, "status", ["afk"]);
16+
events = filter_period_intersect(events, afk);
17+
RETURN = {{"events": events}};
18+
"""
19+
events = aw.query(query=query, timeperiods=timeperiods)
20+
21+
events = [e for e in events[0]["events"] if "title" in e["data"] and e["data"]["title"] == "KomuTracker - Google Chrome"]
22+
23+
return sum((e.duration for e in events), timedelta())
24+
1125
def get_spent_time(aw, email, timeperiods):
1226
canonicalQuery = queries.canonicalEvents(
1327
queries.DesktopQueryParams(
@@ -48,8 +62,7 @@ def main():
4862
dayend = daystart + timedelta(days=1)
4963

5064
timeperiods = [(daystart.astimezone(), dayend.astimezone())]
51-
52-
print(users)
65+
5366
for email in users:
5467
try:
5568
try:
@@ -86,4 +99,4 @@ def main():
8699
#print(reportdata)
87100

88101
if __name__ == "__main__":
89-
main()
102+
main()

0 commit comments

Comments
 (0)