Skip to content

Commit

Permalink
source metrics : added max column
Browse files Browse the repository at this point in the history
  • Loading branch information
luutuankiet committed Feb 25, 2024
1 parent c9d2c1e commit ed6a2f7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 22 deletions.
12 changes: 11 additions & 1 deletion app/charts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ def highlight_row(row):
completed_count_grouped['group'] = 'completed'


st.write(filtered_created_count)
st.write(created_count_grouped)








# TODO : refactor using 3 queries to one cause they use same base except for the datestamp field.
Expand All @@ -322,6 +330,7 @@ def highlight_row(row):
melted_completed_count = completed_count_grouped.melt(id_vars=['group','day_of_year'], value_vars=['tasks_completed'], var_name='task_type', value_name='count')
activities = pd.concat([melted_active_count, melted_created_count, melted_completed_count], ignore_index=True)

st.write(melted_created_count)

# base color "#6281c3",
# Define a color dictionary
Expand Down Expand Up @@ -369,7 +378,8 @@ def highlight_row(row):
y=alt.Y('rolling_mean:Q',title="completed_average")
)




combo_activities = activities_bar+active_line+created_line+completed_line
st.write("## trends over week")
st.altair_chart(combo_activities,use_container_width=True)
Expand Down
24 changes: 15 additions & 9 deletions dbt_project/analyses/completed_counts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@ with source as (
select
coalesce(fld_folder_name,'Default') as fld_folder_name,
coalesce(l_list_name,'Inbox') as l_list_name,
datepart('day',active) as day,
datepart('month',active) as month,
datepart('year',active) as year,
datepart('day',completed) as day,
datepart('month',completed) as month,
datepart('year',completed) as year,
max_day_completed_timestamp,
count(*) as cnt
from
(
select
td_completed_time::timestamp as active,
td_completed_time::timestamp as completed,
max(completed) over(partition by fld_folder_name,l_list_name,datepart('day',completed),datepart('month',completed),datepart('year',completed)) as max_day_completed_timestamp,

*
from obt) a
group by
fld_folder_name,
l_list_name,
datepart('day',active),
datepart('month',active),
datepart('year',active)
datepart('day',completed),
datepart('month',completed),
datepart('year',completed),
max_day_completed_timestamp
),

task_level as (

select
fld_folder_name,
l_list_name,
sum(cnt) as tasks_completed, day,month,year
sum(cnt) as tasks_completed,
max_day_completed_timestamp,
day,month,year

from source group by day,month,year,l_list_name,fld_folder_name
from source group by day,month,year,l_list_name,fld_folder_name,max_day_completed_timestamp


)
Expand Down
24 changes: 15 additions & 9 deletions dbt_project/analyses/created_counts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@ with source as (
select
coalesce(fld_folder_name,'Default') as fld_folder_name,
coalesce(l_list_name,'Inbox') as l_list_name,
datepart('day',active) as day,
datepart('month',active) as month,
datepart('year',active) as year,
datepart('day',created) as day,
datepart('month',created) as month,
datepart('year',created) as year,
max_day_created_timestamp,
count(*) as cnt
from
(
select
td_created_time::timestamp as active,
td_created_time::timestamp as created,
max(created) over(partition by fld_folder_name,l_list_name,datepart('day',created),datepart('month',created),datepart('year',created)) as max_day_created_timestamp,

*
from obt) a
group by
fld_folder_name,
l_list_name,
datepart('day',active),
datepart('month',active),
datepart('year',active)
datepart('day',created),
datepart('month',created),
datepart('year',created),
max_day_created_timestamp
),

task_level as (

select
fld_folder_name,
l_list_name,
sum(cnt) as tasks_created, day,month,year
sum(cnt) as tasks_created,
max_day_created_timestamp,
day,month,year

from source group by day,month,year,l_list_name,fld_folder_name
from source group by day,month,year,l_list_name,fld_folder_name,max_day_created_timestamp


)
Expand Down
11 changes: 8 additions & 3 deletions dbt_project/analyses/modified_counts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ coalesce(l_list_name,'Inbox') as l_list_name,
datepart('day',active) as day,
datepart('month',active) as month,
datepart('year',active) as year,
max_day_active_timestamp,
count(*) as cnt
from
(
select
td_modified_time::timestamp as active,
max(active) over(partition by fld_folder_name,l_list_name,datepart('day',active),datepart('month',active),datepart('year',active)) as max_day_active_timestamp,
*
from obt
) a
Expand All @@ -19,16 +21,19 @@ fld_folder_name,
l_list_name,
datepart('day',active),
datepart('month',active),
datepart('year',active)
datepart('year',active),
max_day_active_timestamp
),

task_level as (
select
fld_folder_name,
l_list_name,
sum(cnt) as tasks_active, day,month,year
sum(cnt) as tasks_active,
max_day_active_timestamp,
day,month,year

from source group by day,month,year,l_list_name,fld_folder_name
from source group by day,month,year,l_list_name,fld_folder_name,max_day_active_timestamp


)
Expand Down

0 comments on commit ed6a2f7

Please sign in to comment.