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
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 31s
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user