Fix granting extra time for another day after task completion

This commit is contained in:
Jonas Lochmann
2022-01-03 01:00:00 +01:00
parent 54faa8cef3
commit 48d7d83db3
11 changed files with 123 additions and 12 deletions
+16 -4
View File
@@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann
* Copyright (C) 2019 - 2022 Jonas Lochmann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -24,11 +24,13 @@ export class ReviewChildTaskAction extends ParentAction {
readonly taskId: string
readonly ok: boolean
readonly time: number
readonly day?: number
constructor ({ taskId, ok, time }: {
constructor ({ taskId, ok, time, day }: {
taskId: string
ok: boolean
time: number
day?: number
}) {
super()
@@ -39,13 +41,22 @@ export class ReviewChildTaskAction extends ParentAction {
throwOutOfRange({ actionType, field: 'time', value: time })
}
if (day !== undefined) {
assertSafeInteger({ actionType, field: 'day', value: day })
if (day < 0) {
throwOutOfRange({ actionType, field: 'day', value: day })
}
}
this.taskId = taskId
this.ok = ok
this.time = time
this.day = day
}
static parse = ({ taskId, ok, time }: SerializedReviewChildTaskAction) => (
new ReviewChildTaskAction({ taskId, ok, time })
static parse = ({ taskId, ok, time, day }: SerializedReviewChildTaskAction) => (
new ReviewChildTaskAction({ taskId, ok, time, day })
)
}
@@ -54,4 +65,5 @@ export interface SerializedReviewChildTaskAction {
taskId: string
ok: boolean
time: number
day?: number
}