Skip to content

Commit 32d81cc

Browse files
committed
changed name of repo to aw-research
1 parent b04372b commit 32d81cc

18 files changed

Lines changed: 64 additions & 183 deletions

aw_analysis/filters.py

Lines changed: 0 additions & 119 deletions
This file was deleted.

aw_analysis/flood.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

aw_analysis/simplify.py

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"__email__", "__license__", "__copyright__",
77
]
88

9-
__title__ = "aw-analysis"
10-
__summary__ = "Analysis library for ActivityWatch"
11-
__uri__ = "https://github.com/ActivityWatch/aw-analysis"
9+
__title__ = "aw-research"
10+
__summary__ = "Research tools for ActivityWatch data"
11+
__uri__ = "https://github.com/ActivityWatch/aw-research"
1212

1313
__version__ = "0.1.0"
1414

aw_research/filters.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import logging
2+
from typing import List
3+
4+
from aw_core.models import Event
5+
from aw_client import ActivityWatchClient
6+
7+
# Function was moved into aw_transform
8+
from aw_transform import filter_keyvals, filter_period_intersect
9+
10+
11+
logger = logging.getLogger(__name__)
12+
13+
14+
def filter_short(events, threshold: float = 1):
15+
# TODO: Try to fill hole in timeline where events have been removed
16+
# (if events before and after where are the same)
17+
# Useful for filtering AFK data and to make data look "smoother".
18+
# Might be something for another function
19+
return [e for e in events if e.duration.total_seconds() > threshold]
20+
21+
22+
def filter_datafields(events: List[Event], fields: List[str]):
23+
"""Filters away specific datafield from every event in a list"""
24+
for e in events:
25+
for field in fields:
26+
if field in e.data:
27+
e.data.pop(field)
28+
return events
29+
30+
31+
def test_filter_data():
32+
awapi = ActivityWatchClient("cleaner", testing=True)
33+
events = awapi.get_events("aw-watcher-web-test", limit=-1)
34+
events = filter_datafields(events, "title")
35+
assert "title" not in events[0].data
36+
37+
38+
def test_filter_short():
39+
# TODO: This was used in dev and does not work.
40+
awapi = ActivityWatchClient("cleaner", testing=True)
41+
events = awapi.get_events("aw-watcher-web-test", limit=-1)
42+
filter_short(events, threshold=1)
43+
44+
events = awapi.get_events("aw-watcher-window-testing_erb-main2-arch", limit=-1)
45+
filter_short(events, threshold=1)
46+
47+
events = awapi.get_events("aw-watcher-afk-testing_erb-main2-arch", limit=-1)
48+
filter_short(events, threshold=30)
49+
50+
51+
if __name__ == "__main__":
52+
test_filter_data()
53+
test_filter_short()

aw_research/flood.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Function was moved
2+
from aw_transform import flood

0 commit comments

Comments
 (0)