Stockage de l'heure de début et des heures de pénalités

This commit is contained in:
Emmy D'Anello 2024-12-07 21:11:37 +01:00
parent 97d61497bc
commit 0a89676b7e
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 33 additions and 8 deletions

View File

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "ChallengeAction" ADD COLUMN "end" TIMESTAMP(3),
ADD COLUMN "penaltyEnd" TIMESTAMP(3),
ADD COLUMN "penaltyStart" TIMESTAMP(3),
ADD COLUMN "start" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

View File

@ -41,13 +41,17 @@ model Challenge {
}
model ChallengeAction {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
challenge Challenge @relation(fields: [challengeId], references: [id])
challengeId Int @unique
active Boolean @default(false)
success Boolean @default(false)
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
challenge Challenge @relation(fields: [challengeId], references: [id])
challengeId Int @unique
active Boolean @default(false)
success Boolean @default(false)
start DateTime @default(now())
end DateTime?
penaltyStart DateTime?
penaltyEnd DateTime?
moneyUpdate MoneyUpdate?
}

View File

@ -1,7 +1,8 @@
import { ApiProperty } from "@nestjs/swagger"
import { ChallengeAction } from "@prisma/client"
import { IsOptional } from "class-validator"
export class ChallengeActionEntity implements ChallengeAction {
export default class ChallengeActionEntity implements ChallengeAction {
constructor(partial: Partial<ChallengeActionEntity>) {
Object.assign(this, partial)
}
@ -20,4 +21,19 @@ export class ChallengeActionEntity implements ChallengeAction {
@ApiProperty({ description: "Est-ce que le défi a été réussi" })
success: boolean
@ApiProperty({ description: "Heure à laquelle le défi a été démarré" })
start: Date
@IsOptional()
@ApiProperty({ description: "Heure à laquelle le défi a été terminé", required: false, nullable: true })
end: Date
@IsOptional()
@ApiProperty({ description: "Heure à laquelle la pénalité a commencé, si applicable", required: false, nullable: true })
penaltyStart: Date
@IsOptional()
@ApiProperty({ description: "Heure à laquelle la pénalité s'est terminée, si applicable", required: false, nullable: true })
penaltyEnd: Date
}