Skip to content

Commit f0eb159

Browse files
committed
Fix grammar
1 parent aea9154 commit f0eb159

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

app.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def add_xp(self, amount): # add XP
4646
flash(
4747
"Task completed! You gained " +
4848
short_numeric_filter(amount) + " XP!"
49-
) # display message with amount of XP earned
49+
) # display message with the amount of XP earned
5050
self.check_level_up() # check if user has leveled up
5151

5252
def check_level_up(self): # check if user has leveled up
@@ -80,7 +80,7 @@ class Task(db.Model):
8080
nullable=False) # task repeat often
8181
times_completed = db.Column(
8282
db.Integer, default=0, nullable=False
83-
) # number of times task has completed
83+
) # number of times tasks has completed
8484
streak = db.Column(db.Integer, default=0, nullable=False) # task streak
8585
completed = db.Column(
8686
db.Boolean, default=False, nullable=False
@@ -141,7 +141,7 @@ def short_numeric_filter(value):
141141
def index(): # get index page template
142142
tasks = Task.query.order_by(
143143
Task.due_date
144-
).all() # get list of tasks sorted by due date
144+
).all() # get the list of tasks sorted by due date
145145
user = User.query.first() # get first user
146146
# get today's date in YYYY-MM-DD format
147147
today = datetime.now().strftime("%Y-%m-%d")
@@ -151,7 +151,7 @@ def index(): # get index page template
151151

152152

153153
@app.route("/add", methods=["POST"])
154-
def add_task(): # add task to task list
154+
def add_task(): # add the task to the task list
155155
name = request.form.get("name") # get name from request form
156156
due_date = request.form.get("due_date") # get due date
157157
priority = int(request.form.get("priority")) # get priority
@@ -172,8 +172,8 @@ def add_task(): # add task to task list
172172
repeat_often=repeat_often,
173173
original_due_date=datetime.strptime(due_date, "%Y-%m-%d"),
174174
due_date=datetime.strptime(due_date, "%Y-%m-%d"),
175-
) # create new task with input parameters
176-
db.session.add(new_task) # add new task to task list
175+
) # create the new task with input parameters
176+
db.session.add(new_task) # add the new task to task list
177177
db.session.commit() # commit database changes
178178
return redirect(url_for("index")) # redirect to index page template
179179

@@ -183,7 +183,7 @@ def complete_task(task_id): # complete task from task id
183183
task = Task.query.get(task_id) # get task by task id
184184
if task:
185185
due_multiplier = 1 # set default due multiplier to 1
186-
if task.repeat_often == 5: # if task is one-time task
186+
if task.repeat_often == 5: # if the task is a one-time task
187187
task.completed = True # complete the task
188188
else: # if task is repeatable
189189
task.times_completed += 1 # increase times task completed by 1
@@ -192,20 +192,20 @@ def complete_task(task_id): # complete task from task id
192192
task.times_completed,
193193
task.repeat_interval,
194194
task.repeat_often,
195-
) # calculate next task due date
195+
) # calculate the next task due date
196196
days_to_due = (
197197
task.due_date - date.today()
198-
).days # calculate number of days until task is due
198+
).days # calculate the number of days until the task is due
199199
if days_to_due > 0: # if task due date is after today
200200
due_multiplier = 1 + 1 / (
201201
days_to_due + 1
202-
) # set due multiplier that increases over time when task is closer to due date
202+
) # set due multiplier that increases over time when the task is closer to due date
203203
elif (
204204
days_to_due < 0
205-
): # if task is overdue (current date is after task due date)
205+
): # if the task is overdue (current date is after task due date)
206206
due_multiplier = -2 / (
207207
days_to_due - 1
208-
) # set due multiplier that decreases over time when task is overdue
208+
) # set due multiplier that decreases over time when the task is overdue
209209
elif days_to_due == 0: # if task due date is today
210210
next_midnight = datetime.combine(
211211
datetime.now().date() + timedelta(days=1), datetime.min.time()
@@ -215,7 +215,7 @@ def complete_task(task_id): # complete task from task id
215215
) # set due multiplier to 2 and increases over time to 4 at midnight
216216
if (
217217
date.today() > task.due_date
218-
): # check if task is overdue (current date is after task due date)
218+
): # check if the task is overdue (current date is after task due date)
219219
task.streak = 0 # reset streak to 0
220220
else:
221221
task.streak += 1 # increase streak by 1
@@ -269,27 +269,27 @@ def complete_task(task_id): # complete task from task id
269269
completed=False
270270
).count() # get number of active tasks (tasks that are not completed)
271271
if user:
272-
user.tasks_completed += 1 # increase number of tasks completed by 1
272+
user.tasks_completed += 1 # increase the number of tasks completed by 1
273273
day_difference = datetime.now() - datetime(
274274
user.last_completion_date.year,
275275
user.last_completion_date.month,
276276
user.last_completion_date.day,
277277
) # calculate difference in days
278278
if day_difference.days == 1: # if a new day has passed
279-
user.daily_streak += 1 # increase daily streak by 1
279+
user.daily_streak += 1 # increase the daily streak by 1
280280
user.daily_tasks_completed = (
281-
1 # reset number of tasks completed in a day to 1
281+
1 # reset the number of tasks completed in a day to 1
282282
)
283283
user.days_completed += 1 # increase days completed by 1
284284
elif day_difference.days > 1: # if more than a day has passed
285-
user.daily_streak = 1 # reset daily streak to 1
285+
user.daily_streak = 1 # reset the daily streak to 1
286286
user.daily_tasks_completed = (
287-
1 # reset number of tasks completed in a day to 1
287+
1 # reset the number of tasks completed in a day to 1
288288
)
289289
user.days_completed += 1 # increase days completed by 1
290290
else:
291291
user.daily_tasks_completed += (
292-
1 # increase number of tasks completed in a day by 1
292+
1 # increase the number of tasks completed in a day by 1
293293
)
294294
user.last_completion_date = (
295295
datetime.now()
@@ -325,15 +325,15 @@ def delete_task(task_id): # delete task from task id
325325

326326
def calculate_next_recurring_event(
327327
original_date, times_completed, repeat_interval, repeat_often
328-
): # calculate next recurring event date
328+
): # calculate the next recurring event date
329329
if repeat_often == 1: # if task repeat often is daily
330330
return original_date + timedelta(
331331
days=repeat_interval * times_completed
332-
) # add days to original date
332+
) # add days to the original date
333333
elif repeat_often == 2: # if task repeat often is weekly
334334
return original_date + timedelta(
335335
weeks=repeat_interval * times_completed
336-
) # add weeks to original date
336+
) # add weeks to the original date
337337
elif repeat_often == 3: # if task repeat often is monthly
338338
new_month = (
339339
original_date.month + repeat_interval * times_completed
@@ -347,7 +347,7 @@ def calculate_next_recurring_event(
347347
] # get number of days in month
348348
return datetime(
349349
new_year, new_month, min(original_date.day, max_days_in_month)
350-
) # add months to original date
350+
) # add months to the original date
351351
elif repeat_often == 4: # if task repeat often is yearly
352352
new_year = original_date.year + repeat_interval * times_completed
353353
max_days_in_month = calendar.monthrange(new_year, original_date.month)[
@@ -368,15 +368,15 @@ def init_db(): # initialize database
368368
db.create_all() # create tables if they don't exist
369369
if "tasks_completed" not in [
370370
column["name"] for column in db.inspect(db.engine).get_columns("user")
371-
]: # check if tasks completed column is not in user table
371+
]: # check if tasks completed column is not in the user table
372372
db.session.execute(
373373
text(
374374
"ALTER TABLE user ADD COLUMN tasks_completed INT NOT NULL DEFAULT 0"
375375
)
376376
) # create tasks completed column
377377
if "last_completion_date" not in [
378378
column["name"] for column in db.inspect(db.engine).get_columns("user")
379-
]: # check if last completion date column is not in user table
379+
]: # check if the last completion date column is not in the user table
380380
db.session.execute(
381381
text(
382382
"ALTER TABLE user ADD COLUMN last_completion_date DATE NOT NULL DEFAULT CURRENT_DATE"
@@ -385,33 +385,33 @@ def init_db(): # initialize database
385385
db.session.commit() # commit database changes
386386
if "daily_streak" not in [
387387
column["name"] for column in db.inspect(db.engine).get_columns("user")
388-
]: # check if tasks completed column is not in user table
388+
]: # check if tasks completed column is not in the user table
389389
db.session.execute(
390390
text("ALTER TABLE user ADD COLUMN daily_streak INT NOT NULL DEFAULT 1")
391391
) # create tasks completed column
392392
if "daily_tasks_completed" not in [
393393
column["name"] for column in db.inspect(db.engine).get_columns("user")
394-
]: # check if daily tasks completed column is not in user table
394+
]: # check if daily tasks completed column is not in the user table
395395
db.session.execute(
396396
text(
397397
"ALTER TABLE user ADD COLUMN daily_tasks_completed INT NOT NULL DEFAULT 0"
398398
)
399399
) # create daily tasks completed column
400400
if "days_completed" not in [
401401
column["name"] for column in db.inspect(db.engine).get_columns("user")
402-
]: # check if days completed column is not in user table
402+
]: # check if days completed column is not in the user table
403403
db.session.execute(
404404
text(
405405
"ALTER TABLE user ADD COLUMN days_completed INT NOT NULL DEFAULT 1"
406406
)
407407
) # create days completed column
408-
if User.query.count() == 0: # if there is no users
408+
if User.query.count() == 0: # if there are no users
409409
new_user = User(username="Player") # create new user
410-
db.session.add(new_user) # add new user to database
410+
db.session.add(new_user) # add new user to the database
411411
db.session.commit() # commit database changes
412412
if "original_due_date" not in [
413413
column["name"] for column in db.inspect(db.engine).get_columns("task")
414-
]: # check if original due date column is not in task table
414+
]: # check if the original due date column is not in the task table
415415
db.session.execute(
416416
text(
417417
"ALTER TABLE task ADD COLUMN original_due_date DATE NOT NULL DEFAULT CURRENT_DATE"
@@ -420,7 +420,7 @@ def init_db(): # initialize database
420420
db.session.commit() # commit database changes
421421
if "due_date" not in [
422422
column["name"] for column in db.inspect(db.engine).get_columns("task")
423-
]: # check if due date column is not in task table
423+
]: # check if due date column is not in the task table
424424
db.session.execute(
425425
text(
426426
"ALTER TABLE task ADD COLUMN due_date DATE NOT NULL DEFAULT CURRENT_DATE"
@@ -429,45 +429,45 @@ def init_db(): # initialize database
429429
db.session.commit() # commit database changes
430430
if "priority" not in [
431431
column["name"] for column in db.inspect(db.engine).get_columns("task")
432-
]: # check if priority column is not in task table
432+
]: # check if priority column is not in the task table
433433
db.session.execute(
434434
text("ALTER TABLE task ADD COLUMN priority INT NOT NULL DEFAULT 1")
435435
) # create priority column
436436
if "difficulty" not in [
437437
column["name"] for column in db.inspect(db.engine).get_columns("task")
438-
]: # check if difficulty column is not in task table
438+
]: # check if difficulty column is not in the task table
439439
db.session.execute(
440440
text("ALTER TABLE task ADD COLUMN difficulty INT NOT NULL DEFAULT 1")
441441
) # create difficulty column
442442
if "repeat_interval" not in [
443443
column["name"] for column in db.inspect(db.engine).get_columns("task")
444-
]: # check if repeat interval column is not in task table
444+
]: # check if repeat interval column is not in the task table
445445
db.session.execute(
446446
text(
447447
"ALTER TABLE task ADD COLUMN repeat_interval INT NOT NULL DEFAULT 1"
448448
)
449449
) # create repeat interval column
450450
if "repeat_often" not in [
451451
column["name"] for column in db.inspect(db.engine).get_columns("task")
452-
]: # check if repeat often column is not in task table
452+
]: # check if repeat often column is not in the task table
453453
db.session.execute(
454454
text("ALTER TABLE task ADD COLUMN repeat_often INT NOT NULL DEFAULT 5")
455455
) # create repeat often column
456456
if "times_completed" not in [
457457
column["name"] for column in db.inspect(db.engine).get_columns("task")
458-
]: # check if times completed column is not in task table
458+
]: # check if times completed column is not in the task table
459459
db.session.execute(
460460
text(
461461
"ALTER TABLE task ADD COLUMN times_completed INT NOT NULL DEFAULT 0"
462462
)
463463
) # create times completed column
464464
if "streak" not in [
465465
column["name"] for column in db.inspect(db.engine).get_columns("task")
466-
]: # check if streak column is not in task table
466+
]: # check if streak column is not in the task table
467467
db.session.execute(
468468
text("ALTER TABLE task ADD COLUMN streak INT NOT NULL DEFAULT 0")
469469
) # create streak column
470-
tasks = Task.query.all() # get list of tasks
470+
tasks = Task.query.all() # get the list of tasks
471471
for task in tasks: # repeat for each task
472472
if (
473473
task.original_due_date is None
@@ -481,7 +481,7 @@ def init_db(): # initialize database
481481
task.priority = 1 # set task priority to low
482482
if task.difficulty is None: # check if task difficulty is none
483483
task.difficulty = 1 # set task difficulty to low
484-
if task.repeat_interval is None: # check if repeat interval is none
484+
if task.repeat_interval is None: # check if the repeat interval is none
485485
task.repeat_interval = 1 # set repeat interval to 1
486486
if task.repeat_often is None: # check if repeat often is none
487487
task.repeat_often = 1 # set repeat often to once

0 commit comments

Comments
 (0)