Open theimperious1 opened 1 month ago
I like the general idea here, but i don't like storing an object as a string in the database
Instead, let's stretch those prisma legs, can you please make a new table for combo breakers? Something like:
` model counting { ... breakers counting_breaks[]
}
model counting_breaks { id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid user_id String game_id String @db.Uuid count Int last_broken_at DateTime @default(now()) @db.Timestamptz(6)
user users @relation(fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "counting_userid_foreign") game counting @relation(fields: [game_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "counting_guildid_foreign")
@@unique([user_id, game_id], map: "counting_userid_gameid_unique") }`
This way it's more extensible and 'proper': Maybe one day we'll want to get a list of how many times each person has broken the combo or something
When you're done, you'll need to create a new migration file that will modify the database. In the package.json there's the 'db:migrateDev' npm script. You'll want to modify 'welcome_fix' to like 'counting_breakers' and then run the script
Just to explain: We use a postgres database, and prisma is a layer between us and the database. We still use migration files to manage the database, but prisma makes it easy and lets us modify the schema file to be what we want it to be, and prisma takes care of generating the migration files for us, so we don't need to actually write (or debug) SQL
Thank you!
This PR should prevent the same user being able to break combos back to back, regardless of which counting game mode they originally broke the combo of.
UPDATE: This now should prevent the last 4 people to have broken the combo from breaking it again. It also fixes formatting issues in the warning before breaking a combo.
Fix #695.