Compare commits
2 Commits
320123ad74
...
b9a575219a
Author | SHA1 | Date | |
---|---|---|---|
b9a575219a | |||
aa792ce33a |
14
init.sql
14
init.sql
@ -47,4 +47,18 @@ from (select td_row_n.t, td_row_n.id, td_row_n.geog
|
|||||||
where td_row_n.row_n = 1) td_end
|
where td_row_n.row_n = 1) td_end
|
||||||
|
|
||||||
on (td_start.id = td_end.id)
|
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,17 +3,8 @@ from tabulate import tabulate
|
|||||||
|
|
||||||
def print_stats(db: Connection):
|
def print_stats(db: Connection):
|
||||||
overall_stats = """
|
overall_stats = """
|
||||||
select distinct
|
select *
|
||||||
td.t::date,
|
from training_info
|
||||||
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)),
|
print(tabulate(list(db.execute(overall_stats)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user