allow for a starting date and hidden hunt if it hasnt started
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 31s

This commit is contained in:
2026-03-19 14:39:06 -04:00
parent 79c0b883f7
commit 34b3a4cbd0
12 changed files with 107 additions and 30 deletions

View File

@@ -141,11 +141,11 @@ const Users = {
// ─── Hunts ────────────────────────────────────────────────
const Hunts = {
create(name, shortName, description, packageCount, expiryDate, createdBy) {
create(name, shortName, description, packageCount, expiryDate, createdBy, startDate, hiddenUntilStart) {
const stmt = db.prepare(
'INSERT INTO hunts (name, short_name, description, package_count, expiry_date, created_by) VALUES (?, ?, ?, ?, ?, ?)'
'INSERT INTO hunts (name, short_name, description, package_count, expiry_date, created_by, start_date, hidden_until_start) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
);
const result = stmt.run(name, shortName.toUpperCase(), description, packageCount, expiryDate || null, createdBy);
const result = stmt.run(name, shortName.toUpperCase(), description, packageCount, expiryDate || null, createdBy, startDate || null, hiddenUntilStart ? 1 : 0);
const huntId = result.lastInsertRowid;
// Generate packages
@@ -217,9 +217,19 @@ const Hunts = {
return !!row;
},
update(id, name, description, expiryDate) {
db.prepare('UPDATE hunts SET name = ?, description = ?, expiry_date = ? WHERE id = ?')
.run(name, description, expiryDate || null, id);
update(id, name, description, expiryDate, startDate, hiddenUntilStart) {
db.prepare('UPDATE hunts SET name = ?, description = ?, expiry_date = ?, start_date = ?, hidden_until_start = ? WHERE id = ?')
.run(name, description, expiryDate || null, startDate || null, hiddenUntilStart ? 1 : 0, id);
},
isHidden(hunt) {
if (!hunt.hidden_until_start || !hunt.start_date) return false;
return new Date(hunt.start_date + 'Z') > new Date();
},
hasStarted(hunt) {
if (!hunt.start_date) return true;
return new Date(hunt.start_date + 'Z') <= new Date();
},
resetScans(id) {