Calculate all Cycles...

This commit is contained in:
Alexander Hosking 2022-04-30 01:38:39 -04:00
parent 43b2a1d6bb
commit 7d6a2e0a78

View File

@ -151,16 +151,15 @@ def cycle_math():
for num, cycle in enumerate(all_cycles): for num, cycle in enumerate(all_cycles):
# http://127.0.0.1:5000/cycle_math # http://127.0.0.1:5000/cycle_math
# cycle length = next start - this start # cycle length = next start - this start
if num > 0: this_start = pendulum.parse(cycle['start_time'])
this_start = pendulum.parse(cycle['start_time']) next_start = pendulum.parse(all_cycles[num-1]['start_time'])
next_start = pendulum.parse(all_cycles[num-1]['start_time']) cycle_length = (next_start - this_start).days
cycle_length = (next_start - this_start).days db.execute(
db.execute( 'UPDATE cycle SET cycle_length = ?'
'UPDATE cycle SET cycle_length = ?' ' WHERE id = ?',
' WHERE id = ?', (cycle_length, cycle['id'])
(cycle_length, cycle['id']) )
) db.commit()
db.commit()
return redirect(url_for('cycles.index')) return redirect(url_for('cycles.index'))