Compare commits
No commits in common. "b9a575219abeccff7c2e91be671dd869c9fe1c1e" and "320123ad74160e8cc1e5a28704f081bb31e5c7da" have entirely different histories.
b9a575219a
...
320123ad74
14
init.sql
14
init.sql
@ -47,18 +47,4 @@ from (select td_row_n.t, td_row_n.id, td_row_n.geog
|
||||
where td_row_n.row_n = 1) td_end
|
||||
|
||||
on (td_start.id = td_end.id)
|
||||
);
|
||||
|
||||
create or replace view training_info as
|
||||
(select distinct
|
||||
td.t::date,
|
||||
date_trunc('second', training_duration.start_time::time) as start_time,
|
||||
date_trunc('second', training_duration.end_time::time) as end_time,
|
||||
training_duration.duration as duration,
|
||||
round(((t.moving_distance)/1000)::numeric, 2) as distance,
|
||||
round(( (t.moving_distance / 1000) / (select extract(epoch from training_duration.duration)/3600))::numeric, 1) as pace_kmh
|
||||
from training t
|
||||
join training_data td on (t.id = td.training_id)
|
||||
join training_duration on (t.id = training_duration.id)
|
||||
order by td.t::date, date_trunc('second', training_duration.start_time::time) asc
|
||||
);
|
13
stats.py
13
stats.py
@ -3,8 +3,17 @@ from tabulate import tabulate
|
||||
|
||||
def print_stats(db: Connection):
|
||||
overall_stats = """
|
||||
select *
|
||||
from training_info
|
||||
select distinct
|
||||
td.t::date,
|
||||
date_trunc('second', training_duration.start_time::time) as start_time,
|
||||
date_trunc('second', training_duration.end_time::time) as end_time,
|
||||
training_duration.duration as duration,
|
||||
round(((t.moving_distance)/1000)::numeric, 2) as distance,
|
||||
round(( (t.moving_distance / 1000) / (select extract(epoch from training_duration.duration)/3600))::numeric, 1) as pace_kmh
|
||||
from training t
|
||||
join training_data td on (t.id = td.training_id)
|
||||
join training_duration on (t.id = training_duration.id)
|
||||
order by td.t::date, date_trunc('second', training_duration.start_time::time) asc
|
||||
"""
|
||||
|
||||
print(tabulate(list(db.execute(overall_stats)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user