Merge branch 'master' of git.ahoskingit.com:family/period

This commit is contained in:
Alexander Hosking 2022-05-08 14:51:10 -04:00
commit d69001d72d

View File

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