diff --git a/crates/core/src/template.rs b/crates/core/src/template.rs index 8a892e3e..b977e633 100644 --- a/crates/core/src/template.rs +++ b/crates/core/src/template.rs @@ -1,5 +1,6 @@ use lazy_static::lazy_static; -use tera::Tera; +use pace_time::duration::PaceDuration; +use tera::{Function, Tera}; use crate::prelude::{ReflectionSummary, SummaryActivityGroup}; @@ -13,7 +14,6 @@ lazy_static! { } }; tera.autoescape_on(vec![".html", ".sql"]); - // tera.register_filter("do_nothing", do_nothing_filter); tera }; } @@ -35,8 +35,14 @@ impl From for PaceReflectionTemplate { context.insert("time_range_start", &value.time_range().start()); context.insert("time_range_end", &value.time_range().end()); - context.insert("total_time_spent", &value.total_time_spent()); - context.insert("total_break_duration", &value.total_break_duration()); + context.insert( + "total_time_spent", + &value.total_time_spent().human_readable(), + ); + context.insert( + "total_break_duration", + &value.total_break_duration().human_readable(), + ); // key must be a string, because of the way tera works with nested objects // we need to convert the key to a string diff --git a/templates/reflections/basic.html b/templates/reflections/basic.html index d0650c0e..de12bdf9 100644 --- a/templates/reflections/basic.html +++ b/templates/reflections/basic.html @@ -33,10 +33,10 @@

Time Range

End: {{ time_range_end }}

Total Time Spent

-

{{ total_time_spent }} seconds

+

{{ total_time_spent }}

Total Break Duration

-

{{ total_break_duration }} seconds

+

{{ total_break_duration }}

Summary Groups by Category

diff --git a/templates/reflections/basic.md b/templates/reflections/basic.md new file mode 100644 index 00000000..6f2920ce --- /dev/null +++ b/templates/reflections/basic.md @@ -0,0 +1,32 @@ +# Activity Reflection + +## Time Range + +Start: **{{time_range_start}}** + +End: **{{time_range_end}}** + +## Overview + +Total Time Spent: **{{total_time_spent}}** + +Total Break Time: **{{total_break_duration}}** + +## Summary Groups By Category + +{% for key, value in summary_groups_by_category %} + +### {{key}} + +Duration: **{{value.total_duration}}s** + +Break Duration (Count): {{value.total_break_duration}}s ({{value.total_break_count}}) + +{% for key2, value2 in value.activity_groups_by_description %} + +#### {{key2}} + +{{value2.description}} + +{% endfor %} +{% endfor %}