Skip to content

Commit

Permalink
added clarifytoday count to daily ops metric
Browse files Browse the repository at this point in the history
  • Loading branch information
luutuankiet committed Feb 27, 2024
1 parent 1ebfbdc commit e861bfb
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions app/charts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,40 @@ def highlight_row(row):
with tab1:
st.write("# your main metrics")
st.write("*to answer the question, how munch do i have in my head?*")

today_table_query = """
select
td_title
,td_due_date
,td_due_date as og_td_due_date
,td_repeatFlag
,fld_folder_name
,l_list_name
,* from obt where
completed_date_id is null
and l_is_active = '1'
and td_kind = 'TEXT'
and fld_folder_name not in ('🚀SOMEDAY lists','🛩Horizon of focus','💤on hold lists')
and l_list_name not like '%tickler note%'
and due_date_id is not null
and td_tags not like '%tickler%'
"""
today_table = get_table_nocache(today_table_query).reset_index(drop=True)

# ajust the timezone
today_table['td_due_date'] = pd.to_datetime(today_table['td_due_date'])
today_table['td_due_date'] = today_table['td_due_date'].dt.tz_localize(tz=adj_timezone)
today_clarify_count_df = today_table[(today_table['td_tags'].str.contains('clarifyme')) &
(today_table['td_title'].str.contains('clarifytoday')) &
((today_table['td_due_date'].dt.date == pd.Timestamp.now(tz=adj_timezone).date()) |
(today_table['td_due_date'].dt.date == pd.to_datetime('1900-01-01T00:00:00').date())
)] # for metrics clarifyme

today_clarify_count = today_clarify_count_df.shape[0] if today_clarify_count_df.shape[0] > 0 else 0


with open(tags_count_path, 'r') as f:
tags_query=f.read()
tags_count = get_table_nocache(tags_query)
Expand Down Expand Up @@ -133,31 +167,6 @@ def highlight_row(row):
clarifyme_avg = 80 # TODO : count average clarifyme across dataset.
delta_clarifyme = clarifyme_count - clarifyme_avg

today_table_query = """
select
td_title
,td_due_date
,td_due_date as og_td_due_date
,td_repeatFlag
,fld_folder_name
,l_list_name
,* from obt where
completed_date_id is null
and l_is_active = '1'
and td_kind = 'TEXT'
and fld_folder_name not in ('🚀SOMEDAY lists','🛩Horizon of focus','💤on hold lists')
and l_list_name not like '%tickler note%'
and due_date_id is not null
and td_tags not like '%tickler%'
"""
today_table = get_table_nocache(today_table_query).reset_index(drop=True)

# ajust the timezone
today_table['td_due_date'] = pd.to_datetime(today_table['td_due_date'])
today_table['td_due_date'] = today_table['td_due_date'].dt.tz_localize(tz=adj_timezone)

overdue_count_df = today_table[today_table['td_due_date'].dt.date < pd.Timestamp.now(tz=adj_timezone).date()]

overdue_count = overdue_count_df.shape[0]
Expand All @@ -166,7 +175,6 @@ def highlight_row(row):
today_count_norepeat_df = today_count_df[today_count_df['td_repeatFlag'] == 'nan']
today_count_repeat_df = today_count_df[today_count_df['td_repeatFlag'] != 'nan']


today_count_norepeat = today_count_norepeat_df.shape[0]
today_count_repeat = today_count_repeat_df.shape[0]
today_count = today_count_norepeat + today_count_repeat
Expand All @@ -193,7 +201,7 @@ def highlight_row(row):
with col2:
st.metric(
label="tasks lined up",
value=f"{today_count_norepeat} | {today_count_repeat} recur",
value=f"{today_count_norepeat} unique | {today_count_repeat} recur",
delta = f"{delta_today} than usual {today_avg} tasks" if today_count_norepeat > 0 else "all's well.",
delta_color="inverse" if today_count_norepeat > 0 else "off",
)
Expand Down Expand Up @@ -221,10 +229,16 @@ def highlight_row(row):
with col4:
st.metric(
label="Clarifyme count",
value=clarifyme_count,
value=f"{clarifyme_count} all | {today_clarify_count} clarifytoday",
delta=f'{delta_clarifyme} than weekly average {clarifyme_avg}' if clarify_progress > 80 else f"clarify them!!! clarification at {clarify_progress}% progress",
delta_color="inverse" if clarifyme_count > 0 else "off",
)
if today_clarify_count > 0:
with st.expander("query"):
st.write("clarifytoday count:")
st.dataframe(today_clarify_count_df,hide_index=True)
else:
pass

st.divider()
st.write("## look ahead")
Expand Down

0 comments on commit e861bfb

Please sign in to comment.