Update Math on Cycle Length

This commit is contained in:
Alexander Hosking 2022-08-12 00:20:19 -04:00
parent 87f936c331
commit fa7d46623e

View File

@ -17,7 +17,7 @@ def index():
db = get_db()
current_cycle = db.execute('SELECT * from cycle ORDER BY id DESC LIMIT 1').fetchone()
start_time = pendulum.parse(current_cycle['start_time'])
cycle_length = ((pendulum.now() - start_time ).days)+1
cycle_length = ((pendulum.now() - start_time ).days) +1
db.execute(
'UPDATE cycle SET cycle_length = ?'
@ -49,7 +49,7 @@ def create():
error = "You must provide a start date"
if end_time > start_time:
cycle_length = (end_time - start_time).days
cycle_length = (end_time - start_time).days +1
else:
cycle_length = (pendulum.now() - start_time).days
@ -105,7 +105,7 @@ def update(id):
error = "You must provide a start date"
if end_time > start_time:
cycle_length = (end_time - start_time).days
cycle_length = (end_time - start_time).days + 1
else:
cycle_length = (pendulum.now() - start_time).days
@ -154,7 +154,7 @@ def cycle_math():
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
cycle_length = (next_start - this_start).days +1
db.execute(
'UPDATE cycle SET cycle_length = ?'
' WHERE id = ?',