ENH add clock time start/end to all_tasks

This commit is contained in:
Nathan Dwarshuis 2021-02-16 23:59:52 -05:00
parent b2b18f0b10
commit 78f6d2bf70
1 changed files with 21 additions and 5 deletions

View File

@ -114,9 +114,11 @@ select distinct
create temporary table _clock_sums as create temporary table _clock_sums as
select select
c.headline_id, c.headline_id,
c.time_start as clock_start,
c.time_end as clock_end,
sum(c.time_end - c.time_start) / 60.0 as clock_sum sum(c.time_end - c.time_start) / 60.0 as clock_sum
from clocks c from clocks c
group by c.headline_id; group by c.headline_id, c.time_start, c.time_end;
-- clock sums partitioned by DONE -> TODO state changes (this mostly useful for -- clock sums partitioned by DONE -> TODO state changes (this mostly useful for
-- repeaters although all headlines are included in this calculation) -- repeaters although all headlines are included in this calculation)
@ -253,8 +255,8 @@ with
select select
g.headline_id, g.headline_id,
g.grp, g.grp,
min(g.time_start) as partitioned_time_start, min(g.time_start) as partitioned_clock_start,
max(g.time_end) as partitioned_time_end, max(g.time_end) as partitioned_clock_end,
sum(g.time_end - g.time_start) / 60.0 as partitioned_clock_sum sum(g.time_end - g.time_start) / 60.0 as partitioned_clock_sum
from grouped g from grouped g
where where
@ -264,8 +266,8 @@ with
select select
o.headline_id, o.headline_id,
o.state_change_id, o.state_change_id,
s.partitioned_time_start, s.partitioned_clock_start,
s.partitioned_time_end, s.partitioned_clock_end,
s.partitioned_clock_sum s.partitioned_clock_sum
from ids o from ids o
left join sums s using (headline_id, grp); left join sums s using (headline_id, grp);
@ -273,6 +275,8 @@ with
create temporary table _habit_headlines as create temporary table _habit_headlines as
select select
r.*, r.*,
cs.partitioned_clock_start,
cs.partitioned_clock_end,
cs.partitioned_clock_sum, cs.partitioned_clock_sum,
s.state_old, s.state_old,
s.state_new, s.state_new,
@ -292,6 +296,8 @@ select
create temporary table _repeater_headlines as create temporary table _repeater_headlines as
select select
r.*, r.*,
cs.partitioned_clock_start,
cs.partitioned_clock_end,
cs.partitioned_clock_sum, cs.partitioned_clock_sum,
s.state_old, s.state_old,
s.state_new, s.state_new,
@ -447,6 +453,8 @@ with
select select
r.headline_id, r.headline_id,
r.state_new as keyword, r.state_new as keyword,
r.partitioned_clock_start as clock_start,
r.partitioned_clock_end as clock_end,
r.partitioned_clock_sum as clock_sum, r.partitioned_clock_sum as clock_sum,
r.closed_timestamp, r.closed_timestamp,
'repeater' as task_type 'repeater' as task_type
@ -455,6 +463,8 @@ with
select select
h.headline_id, h.headline_id,
h.state_new as keyword, h.state_new as keyword,
h.partitioned_clock_start as clock_start,
h.partitioned_clock_end as clock_end,
h.partitioned_clock_sum as clock_sum, h.partitioned_clock_sum as clock_sum,
h.closed_timestamp, h.closed_timestamp,
'habit' as task_type 'habit' as task_type
@ -464,6 +474,8 @@ with
select select
a.headline_id, a.headline_id,
a.keyword, a.keyword,
cs.clock_start,
cs.clock_end,
cs.clock_sum, cs.clock_sum,
to_timestamp(c.time_start) as closed_timestamp, to_timestamp(c.time_start) as closed_timestamp,
'atomic' as task_type 'atomic' as task_type
@ -474,6 +486,8 @@ with
select select
p.headline_id, p.headline_id,
p.keyword, p.keyword,
cs.clock_start,
cs.clock_end,
cs.clock_sum, cs.clock_sum,
to_timestamp(c.time_start) as closed_timestamp, to_timestamp(c.time_start) as closed_timestamp,
'project' as task_type 'project' as task_type
@ -484,6 +498,8 @@ with
select select
i.headline_id, i.headline_id,
i.keyword, i.keyword,
cs.clock_start,
cs.clock_end,
cs.clock_sum, cs.clock_sum,
to_timestamp(c.time_start) as closed_timestamp, to_timestamp(c.time_start) as closed_timestamp,
'iterator' as task_type 'iterator' as task_type