Skip to content

Commit

Permalink
fix: misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Jul 6, 2022
1 parent a58602b commit b6983c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/quantifiedme/activitywatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
import click

from aw_core import Event
from aw_client import ActivityWatchClient
from aw_transform.union_no_overlap import union_no_overlap

import aw_research
import aw_research.classify
from aw_research import verify_no_overlap, split_into_weeks
from aw_research import (
split_event_on_hour,
categorytime_per_day,
categorytime_during_day,
)
from aw_research import categorytime_per_day

from .load_toggl import load_toggl

Expand Down Expand Up @@ -126,6 +123,7 @@ def load_complete_timeline(
personal: bool,
testing: bool = False,
cache: bool = True,
awc: ActivityWatchClient = None,
):
now = datetime.now(tz=timezone.utc)

Expand All @@ -147,6 +145,8 @@ def load_complete_timeline(
events: List[Event] = []

if "activitywatch" in datasources:
if awc is None:
awc = ActivityWatchClient(testing=testing)
for hostname in hostnames:
logger.info(f"Getting events for {hostname}...")
# Split up into previous days and today, to take advantage of caching
Expand All @@ -155,12 +155,12 @@ def load_complete_timeline(
events_aw: List[Event] = []
for dtstart, dtend in split_into_weeks(since, now):
events_aw += aw_research.classify.get_events(
awc,
hostname,
since=dtstart,
end=dtend,
include_smartertime=False,
include_toggl=False,
testing=testing,
)
logger.debug(f"{len(events_aw)} events retreived")
for e in events_aw:
Expand Down
6 changes: 3 additions & 3 deletions src/quantifiedme/oura.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ def load_data():
return data


def load_sleep_df():
def load_sleep_df() -> pd.DataFrame:
data = load_data()
df = pd.DataFrame(data["sleep"])
df["summary_date"] = pd.to_datetime(df["summary_date"])
df = df.set_index("summary_date")
return df


def load_readiness_df():
def load_readiness_df() -> pd.DataFrame:
data = load_data()
df = pd.DataFrame(data["readiness"])
df["summary_date"] = pd.to_datetime(df["summary_date"])
df = df.set_index("summary_date")
return df


def load_activity_df():
def load_activity_df() -> pd.DataFrame:
data = load_data()
df = pd.DataFrame(data["activity"])
df["summary_date"] = pd.to_datetime(df["summary_date"])
Expand Down

0 comments on commit b6983c4

Please sign in to comment.