-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks_completed.py
87 lines (68 loc) · 1.83 KB
/
tasks_completed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# by Dr. Torben Menke https://entorb.net
# https://github.com/entorb/rememberthemilk
"""
RTM tasks completed this year.
by Dr. Torben Menke https://entorb.net
"""
import datetime as dt
from pandas import DataFrame
from helper import (
DATE_TODAY,
df_name_url_to_html,
df_to_html,
get_lists_dict,
get_tasks_as_df,
)
DATE_START = DATE_TODAY - dt.timedelta(days=365)
FILTER_COMPLETED = f"""
CompletedAfter:{DATE_START.strftime("%d/%m/%Y")}
AND NOT list:Taschengeld"""
def get_tasks_completed() -> DataFrame: # noqa: D103
lists_dict = get_lists_dict()
df = get_tasks_as_df(
my_filter=FILTER_COMPLETED,
lists_dict=lists_dict,
)
df = df.sort_values(
by=["completed", "prio", "name"], ascending=[False, False, True]
)
df = df.reset_index()
cols = [
"name",
"list",
"completed",
"completed_week",
# "due",
"overdue",
"prio",
"overdue_prio",
"postponed",
"estimate",
"url",
]
df = df[cols]
return df
def completed_week(df: DataFrame) -> DataFrame: # noqa: D103
df = (
df.groupby(["completed_week", "list"])
.agg(
count=("completed_week", "count"),
sum_prio=("prio", "sum"),
sum_overdue_prio=("overdue_prio", "sum"),
sum_estimate=("estimate", "sum"),
)
.sort_values(by=["completed_week", "list"], ascending=[False, True])
)
return df
if __name__ == "__main__":
df = get_tasks_completed()
print("# RTM tasks completed this year")
df = df_name_url_to_html(df)
df_to_html(
df,
"out-completed.html",
)
# df.to_excel(output_dir/"out-done-year.xlsx", index=False)
df2 = completed_week(df)
print(df2)
df_to_html(df2, "out-completed-week.html", index=True)