Skip to content

Commit

Permalink
init code breakdown today lineup metric to recurr and non recurr
Browse files Browse the repository at this point in the history
  • Loading branch information
luutuankiet committed Feb 23, 2024
1 parent 1356dee commit 432d8c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
19 changes: 14 additions & 5 deletions app/charts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def highlight_row(row):

today_table_query = """
select
due_date_id,count(*) as cnt from
due_date_id,td_repeatFlag,count(*) as cnt from
(
select * from obt where
Expand All @@ -124,17 +124,25 @@ def highlight_row(row):
and l_list_name not like '%tickler note%'
) new
where due_date_id is not null
group by due_date_id
group by due_date_id,td_repeatFlag
"""
today_table = get_table_nocache(today_table_query).reset_index(drop=True)
overdue_count = today_table[today_table['due_date_id'] < pd.to_datetime(datetime.datetime.now().date())]
overdue_count = overdue_count['cnt'].iloc[0] if overdue_count.shape[0] > 0 else 0

today_count = today_table[today_table['due_date_id'] == pd.to_datetime(datetime.datetime.now().date())]
today_count = today_count['cnt'].iloc[0] if today_count.shape[0] > 0 else 0
today_count_norepeat = today_count[today_count['td_repeatFlag'] == 'nan']
today_count_repeat = today_count[today_count['td_repeatFlag'] != 'nan']


today_count_norepeat = today_count_norepeat['cnt'].iloc[0] if today_count_norepeat.shape[0] > 0 else 0
today_count_repeat = today_count_repeat['cnt'].iloc[0] if today_count_repeat.shape[0] > 0 else 0
today_count = today_count_norepeat + today_count_repeat


today_avg = 8 # TODO : implement average count over dataset.
delta_today = today_count - today_avg
delta_today = today_count_norepeat - today_avg


col1,col2,col3,col4 = st.columns(4)
Expand Down Expand Up @@ -169,14 +177,15 @@ def highlight_row(row):
with col2:
st.metric(
label="tasks lined up",
value=today_count,
value=f"{today_count_norepeat} | {today_count_repeat} recur",
delta = f"{delta_today} than usual {today_avg} tasks" if today_count > 0 else "all's well.",
delta_color="inverse" if today_count > 0 else "off",
)
with st.expander("query"):
debug_today_count=get_table_nocache("""
select
due_date_id::date as due_date_id,
td_repeatFlag,
td_created_time::timestamp as td_created_time,
td_modified_time::timestamp as td_modified_time,
fld_folder_name,
Expand Down
14 changes: 14 additions & 0 deletions dbt_project/analyses/draft.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select
due_date_id,td_repeatFlag,count(*) as cnt from

(
select * 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%'
) new
where due_date_id is not null
group by due_date_id,td_repeatFlag
having td_repeatFlag = 'nan'

0 comments on commit 432d8c2

Please sign in to comment.