feat: drop attendance marks and bullet volunteer names with the sunburst
Coordinators no longer record who came. Public roster names use the sunburst as a bullet.
This commit is contained in:
1 parent
1a8959c86a
commit
df3165f6a8
15 files changed
+68
-247
No files matched your search
@@ -10,7 +10,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
**This is not ready for a public launch, and it is not ready for real volunteer records.** Phase 1A has public browsing, individual signup, cancellation, queued email, and coordinator sign-in for events, one-off shifts, rosters, and cancellation. A coordinator can add a walk-in, mark attendance, and move a signup from a shift roster. A volunteer can switch shifts from their private link. An active weekly template fills shifts for the next three months. A coordinator can add, change, or end a weekly template, and can remove a cancelled person, a finished empty shift, an ended template, or an event that is off the public list and already empty. A confirmed signup can receive a reminder 48 hours before the shift and again 2 hours before, and can turn reminders off without cancelling. A coordinator can download a roster for one shift, one event, or a local date range. A coordinator can import a contact list, download it, open a person to see current and past shifts, use a saved contact when adding a walk-in, and add a saved contact to an open shift. A coordinator can set the two reminder times, the reply-to address, how many months to keep a signup, and the wording on the privacy page. A signed-in administrator can add another administrator. Removing someone takes away their sign-in access. The last administrator cannot be removed. After 1:00 AM Central Time, signups older than that many months lose their name and contact details in this app. After 2:30 AM Central Time, the app saves a database backup on this computer. A container can run that same app on this computer, on port 3020, without opening it to the network. This is not a public launch. Around 1:00 AM in each event's time zone, the app adds any missing weekly shifts for the next eight weeks, once that local day. Development prints mail in the server log. It does not send real email.
|
||||
**This is not ready for a public launch, and it is not ready for real volunteer records.** Phase 1A has public browsing, individual signup, cancellation, queued email, and coordinator sign-in for events, one-off shifts, rosters, and cancellation. A coordinator can add a walk-in and move a signup from a shift roster. A volunteer can switch shifts from their private link. An active weekly template fills shifts for the next three months. A coordinator can add, change, or end a weekly template, and can remove a cancelled person, a finished empty shift, an ended template, or an event that is off the public list and already empty. A confirmed signup can receive a reminder 48 hours before the shift and again 2 hours before, and can turn reminders off without cancelling. A coordinator can download a roster for one shift, one event, or a local date range. A coordinator can import a contact list, download it, open a person to see current and past shifts, use a saved contact when adding a walk-in, and add a saved contact to an open shift. A coordinator can set the two reminder times, the reply-to address, how many months to keep a signup, and the wording on the privacy page. A signed-in administrator can add another administrator. Removing someone takes away their sign-in access. The last administrator cannot be removed. After 1:00 AM Central Time, signups older than that many months lose their name and contact details in this app. After 2:30 AM Central Time, the app saves a database backup on this computer. A container can run that same app on this computer, on port 3020, without opening it to the network. This is not a public launch. Around 1:00 AM in each event's time zone, the app adds any missing weekly shifts for the next eight weeks, once that local day. Development prints mail in the server log. It does not send real email.
|
||||
|
||||
## Current step
|
||||
|
||||
@@ -23,7 +23,6 @@ You should have received a copy of the GNU General Public License along with thi
|
||||
| Confirmation and cancellation email | Done |
|
||||
| Coordinator sign-in, events, one-off shifts, roster, and cancellation | Done |
|
||||
| Add a walk-in from a shift roster | Done |
|
||||
| Mark attendance on a shift roster | Done |
|
||||
| Move a signup to another shift | Done |
|
||||
| Switch your own signup to another shift | Done |
|
||||
| Manage other signups from one private link | Disabled; requires a separate verified identity flow |
|
||||
@@ -83,8 +82,6 @@ After sign-in, `/admin` lists events, including events that are off the public l
|
||||
|
||||
On an open shift, **Add a walk-in** records one person who is here. It takes one spot, uses the same person rule as the public form, and queues a confirmation email. The name is listed on the public sign-up page when that shift is posted there. Email and notes stay off that page. A full, cancelled, or ended shift does not take a walk-in.
|
||||
|
||||
On a confirmed signup, **Attended** and **No-show** record whether that person came. **Clear** removes the mark. The mark stays on the roster. It does not send email, and it does not change how many spots are open. A cancelled signup cannot be marked.
|
||||
|
||||
**Move to** puts that person on another open shift in the same event. The first shift gets its spot back and keeps the signup as cancelled. The other shift takes one spot. A change email is queued, and a reminder that is still waiting is dropped. The old private link stops working. The new link is in the change email. A full, cancelled, or ended shift cannot receive the person. A shift that already has that person cannot receive them again. Someone else at the same email can. A failed move leaves them on the original shift.
|
||||
|
||||
On the private signup page, **Switch to** does the same thing for the volunteer. The next page has the new link. A full, cancelled, ended, or unpublished shift is not offered. A switch is rejected if that name and email already occupy the destination shift. The destination list does not reveal which other shifts match those details. If the switch cannot be saved, the original signup stays.
|
||||
@@ -101,7 +98,7 @@ Public switching permits 10 validated attempts per IP per 10-minute window and 5
|
||||
|
||||
A reminder is queued at each saved time before a confirmed signup, while the shift has not started. The defaults are 48 hours before and 2 hours before. The check runs every five minutes. If the app was off and more than one reminder is already due, only the closest one is sent. A person who signs up after an earlier reminder was due does not get that missed reminder. A reminder is not sent after the shift starts. Changing the shift, moving the signup, or cancelling it drops a reminder that has not been sent yet. Mail that was already accepted cannot be recalled. **Stop reminder emails**, on the private signup page or in the reminder itself, turns reminders off for that signup. The signup stays. Confirmation, change, and cancellation emails still arrive. The reminder asks the person to use the link in the confirmation email to cancel. Mail sent to the reply-to address is read by the pantry.
|
||||
|
||||
**Download this roster**, on a shift, and **Download this event**, on an event, save a spreadsheet of the signups. **Download this date range**, on the coordinator page, uses each event's local shift date. The file includes cancelled signups and attendance. A cell that would be a spreadsheet formula is saved as text. The download is not cached. A copy on a coordinator's computer is outside this app, and the app does not delete it later.
|
||||
**Download this roster**, on a shift, and **Download this event**, on an event, save a spreadsheet of the signups. **Download this date range**, on the coordinator page, uses each event's local shift date. The file includes cancelled signups. A cell that would be a spreadsheet formula is saved as text. The download is not cached. A copy on a coordinator's computer is outside this app, and the app does not delete it later.
|
||||
|
||||
**Contacts**, on the coordinator page, keeps a list of people. A confirmed signup is saved on this list. The name is split at the last space. A signup name with no space is saved with a hyphen as the last name. A different name is a separate contact, even when the email matches. The same name and email updates that contact. Cancelling the signup does not remove the contact. Saving someone here does not sign them up for a shift. The list is at the top of this page. **Add a contact**, **Import**, and **Download** stay closed until one is opened. **Import** reads a spreadsheet with First Name, Last Name, Email, and Phone, including the SignUpGenius people export. An Address column is ignored. The same name and email updates that person. A different name stays a separate person, even when the email matches. A different email stays a separate person, even when the name matches. A row without a phone is skipped. Names are capitalized. A word that already mixes upper and lower case stays as written. A phone number with ten digits is saved with dashes, like 712-555-0100. A leading 1 is left off. Email addresses are stored in lowercase. Importing does not take a spot and does not send email. **Download** saves that list. A cell that would be a spreadsheet formula is saved as text. A downloaded copy stays on the coordinator's computer. The signup retention job does not clear this list. The list is the contacts table in `app.db`. The list shows 20 people. **See more** shows the next 20 on this page, without returning to the top, and keeps a search. **Choose a name** to see the shifts they are signed up for and every past shift they signed up for. The signup has to use the same name and email. A signup name with no space matches the contact saved with a hyphen for the last name. A confirmed signup on a shift that has not ended is listed under Signed up for. A shift that has ended is listed under Past shifts, including a cancelled signup, which is marked cancelled. Choosing the shift opens it. Signup details cleared by retention drop off this page. **Edit contact** and **Add to a shift** stay closed until opened. **Add to a shift** uses their saved name, email, and phone. That takes one spot and queues a confirmation email. A full, cancelled, or ended shift is not in that list, and a shift they are already on is not in that list. A shift that is not on the public list can still be chosen. **Edit contact**, on that page, saves a corrected name, email, or phone on the same person. A phone typo can be replaced. A hyphen saved as the last name can be replaced with the real last name. Changing the name does not create a second person, even when the email stays the same. Phone is required. It does not change a signup, take a spot, or send email. **Remove** deletes that person from the list only. On an open shift, **Saved contact** fills a walk-in. The walk-in still takes one spot and queues a confirmation email. **Add a contact** saves one person who has not signed up. It does not take a spot and does not send email. The same name and email updates that person. A different name is saved separately, even with the same email. Typing a walk-in who is not on the list saves them here too.
|
||||
|
||||
@@ -111,7 +108,7 @@ A reminder is queued at each saved time before a confirmed signup, while the shi
|
||||
|
||||
Around 1:00 AM in an event's time zone, the app adds any missing shifts from that event's active weekly templates. It does this once for that local date. If 1:00 happens twice when the clocks change, the second hour does not add them again. If 1:00 does not exist that day, the fill runs once the local clock is past 1:00. A restart later that day still fills the date if it was missed. A date that already has a shift, including a cancelled one, stays as it is. Starting the app, and **Add weekly shifts**, still fill the schedule as well.
|
||||
|
||||
After 1:00 AM Central Time, once that local date, the app removes the name, email, phone, notes, and private link from each signup whose shift ended more than the saved number of months ago. The default is 24. The shift, the signup status, and attendance stay, so the count remains. Legacy guardian columns, when present, are cleared too. A spreadsheet downloaded from an old shift leaves those personal cells blank. This changes the live database. It does not change a spreadsheet already on a coordinator's computer, a message already in someone's inbox, or an older database backup. Clearing a value does not promise that the old bytes are immediately gone from the disk. The contact list is separate. Clearing an old signup does not remove that person from the contact list.
|
||||
After 1:00 AM Central Time, once that local date, the app removes the name, email, phone, notes, and private link from each signup whose shift ended more than the saved number of months ago. The default is 24. The shift and the signup status stay, so the count remains. Legacy guardian columns, when present, are cleared too. A spreadsheet downloaded from an old shift leaves those personal cells blank. This changes the live database. It does not change a spreadsheet already on a coordinator's computer, a message already in someone's inbox, or an older database backup. Clearing a value does not promise that the old bytes are immediately gone from the disk. The contact list is separate. Clearing an old signup does not remove that person from the contact list.
|
||||
|
||||
Finished mail loses its recipient, subject, and body 30 days after it was sent, cancelled, or given up on. Mail that is still waiting after 30 days is cancelled and cleared, so it is not sent late. Mail for a signup is cleared in the same cleanup that removes that signup's details. A sign-in message is cleared once its link is used or expired. Every hour, the app clears those sign-in messages, finished mail past 30 days, expired sign-in sessions, used or expired sign-in links, and rate-limit counters older than about two days. Audit notes older than 24 months are deleted. Those notes are counts and ids. Starting the app runs this cleanup before it accepts requests. If 1:00 AM happens twice when the clocks change, the second hour does not run it again. A restart after 1:00 AM still runs it when that date was missed.
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Attendance is no longer recorded. Marks already stored are discarded.
|
||||
ALTER TABLE signups DROP COLUMN attended;
|
||||
+14
-15
@@ -120,7 +120,6 @@ main:focus-visible {
|
||||
a.btn,
|
||||
button,
|
||||
.inline-form button,
|
||||
.attendance-actions button,
|
||||
.move-form button,
|
||||
.signup-form button,
|
||||
.cancel-form button {
|
||||
@@ -679,9 +678,22 @@ main a:hover {
|
||||
}
|
||||
|
||||
.roster-names li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
padding: 0.12rem 0;
|
||||
}
|
||||
|
||||
.roster-names li span {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.roster-mark {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.roster-empty {
|
||||
margin: 0;
|
||||
color: var(--hope-ink-2);
|
||||
@@ -1298,8 +1310,7 @@ article.shift-card {
|
||||
.signup-form button,
|
||||
.cancel-form button,
|
||||
.move-form button,
|
||||
.inline-form button,
|
||||
.attendance-actions button {
|
||||
.inline-form button {
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
@@ -1375,18 +1386,6 @@ article.shift-card {
|
||||
background: var(--hope-blue-50);
|
||||
}
|
||||
|
||||
.attendance-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
|
||||
.attendance-actions button[aria-pressed="true"] {
|
||||
outline: 3px solid var(--hope-ink);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.inline-form {
|
||||
display: flex;
|
||||
margin-top: 0.75rem;
|
||||
|
||||
@@ -40,11 +40,9 @@ import {
|
||||
listMoveTargets,
|
||||
listOpenShiftsForPerson,
|
||||
moveSignup,
|
||||
setAttendance,
|
||||
updateEvent,
|
||||
updateShift,
|
||||
updateTemplate,
|
||||
type AttendanceMark,
|
||||
} from './admin/store.js';
|
||||
import {
|
||||
AdminHome,
|
||||
@@ -191,7 +189,6 @@ export function registerAdmin(app: Hono, services: AdminServices): void {
|
||||
app.post(appPath(config, '/admin/signups/:id/remove'), (c) => submitRemoveSignup(c, services));
|
||||
app.get(appPath(config, '/admin/signups/:id/cancel'), (c) => showCancelSignup(c, services));
|
||||
app.post(appPath(config, '/admin/signups/:id/cancel'), (c) => submitCancelSignup(c, services));
|
||||
app.post(appPath(config, '/admin/signups/:id/attendance'), (c) => submitAttendance(c, services));
|
||||
app.post(appPath(config, '/admin/signups/:id/move'), (c) => submitMove(c, services));
|
||||
}
|
||||
|
||||
@@ -1391,31 +1388,6 @@ async function submitCancelShift(c: Context, services: AdminServices): Promise<R
|
||||
}
|
||||
}
|
||||
|
||||
async function submitAttendance(c: Context, services: AdminServices): Promise<Response> {
|
||||
const session = await postedSession(c, services);
|
||||
if (session instanceof Response) return session;
|
||||
const mark = textField(session.body, 'mark');
|
||||
if (!isAttendanceMark(mark)) {
|
||||
return html(c, services, 'Coordinator · Hope Volunteer', <MessagePage heading="Coordinator" message="Choose attended or no-show." />, {
|
||||
status: 400,
|
||||
account: session,
|
||||
});
|
||||
}
|
||||
try {
|
||||
const result = setAttendance(services.db, session.coordinatorId, idFrom(c), mark, services.now());
|
||||
if (!result.ok) {
|
||||
return html(c, services, 'Coordinator · Hope Volunteer', <MessagePage heading="Coordinator" message={result.error} />, {
|
||||
status: 400,
|
||||
account: session,
|
||||
});
|
||||
}
|
||||
const notice = mark === 'attended' ? 'attended' : mark === 'no-show' ? 'no-show' : 'attendance-cleared';
|
||||
return c.redirect(appPath(services.config, `/admin/shifts/${result.shiftId}?notice=${notice}`), 303);
|
||||
} catch (err) {
|
||||
return saveFailed(c, services, session, err);
|
||||
}
|
||||
}
|
||||
|
||||
async function submitMove(c: Context, services: AdminServices): Promise<Response> {
|
||||
const session = await postedSession(c, services);
|
||||
if (session instanceof Response) return session;
|
||||
@@ -1595,9 +1567,6 @@ function knownNotice(value: string | undefined): string | undefined {
|
||||
value === 'shift-cancelled' ||
|
||||
value === 'shift-closed' ||
|
||||
value === 'walk-in' ||
|
||||
value === 'attended' ||
|
||||
value === 'no-show' ||
|
||||
value === 'attendance-cleared' ||
|
||||
value === 'moved' ||
|
||||
value === 'generated' ||
|
||||
value === 'no-template' ||
|
||||
@@ -1646,10 +1615,6 @@ function blankWalkIn(
|
||||
};
|
||||
}
|
||||
|
||||
function isAttendanceMark(value: string): value is AttendanceMark {
|
||||
return value === 'attended' || value === 'no-show' || value === 'clear';
|
||||
}
|
||||
|
||||
function signupValuesFrom(body: Record<string, unknown>): SignupValues {
|
||||
return {
|
||||
name: textField(body, 'name'),
|
||||
|
||||
@@ -974,7 +974,6 @@ export function ShiftRoster(props: {
|
||||
) : null}
|
||||
</div>
|
||||
<p class="panel-note">Cancelling a signup emails them. Their old private link stops working, and the email includes a new one.</p>
|
||||
<p class="panel-note">Attendance stays on this roster. It does not send email, and it does not change how many spots are open.</p>
|
||||
<p class="panel-note">Moving a confirmed signup opens this spot and queues a change email. Their old private link stops working.</p>
|
||||
{props.moves && props.moves.targets.length === 0 ? <p class="panel-note">No other open shift in this event has room.</p> : null}
|
||||
{props.shift.people.length === 0 ? (
|
||||
@@ -1782,21 +1781,6 @@ function Roster(props: { config: AppConfig; csrf: string; people: RosterPerson[]
|
||||
) : null}
|
||||
{person.status === 'confirmed' ? (
|
||||
<>
|
||||
<p>{attendanceLabel(person.attendance)}</p>
|
||||
<form method="post" action={appPath(props.config, `/admin/signups/${person.id}/attendance`)} class="attendance-actions">
|
||||
<input type="hidden" name="csrf" value={props.csrf} />
|
||||
<button type="submit" name="mark" value="attended" aria-pressed={person.attendance === 'attended' ? 'true' : 'false'}>
|
||||
Attended
|
||||
</button>
|
||||
<button type="submit" name="mark" value="no-show" aria-pressed={person.attendance === 'no-show' ? 'true' : 'false'}>
|
||||
No-show
|
||||
</button>
|
||||
{person.attendance ? (
|
||||
<button type="submit" name="mark" value="clear">
|
||||
Clear
|
||||
</button>
|
||||
) : null}
|
||||
</form>
|
||||
<p>
|
||||
<ConfirmAnchor
|
||||
class="text-action"
|
||||
@@ -1912,12 +1896,6 @@ function MassRemove(props: { pick: 'shift' | 'signup'; action: string; title: st
|
||||
);
|
||||
}
|
||||
|
||||
function attendanceLabel(attendance: RosterPerson['attendance']): string {
|
||||
if (attendance === 'attended') return 'Attended.';
|
||||
if (attendance === 'no-show') return 'No-show.';
|
||||
return 'Attendance is not marked.';
|
||||
}
|
||||
|
||||
function spotClass(shift: Pick<AdminShiftSummary, 'capacity' | 'occupied' | 'cancelled'>): string {
|
||||
if (shift.cancelled) return 'event-pill is-hidden';
|
||||
return shift.occupied >= shift.capacity ? 'event-pill is-full' : 'event-pill is-open';
|
||||
@@ -1935,9 +1913,6 @@ const NOTICES: Record<string, string> = {
|
||||
'shift-cancelled': 'The shift is cancelled. Cancellation emails are queued.',
|
||||
'shift-closed': 'The shift is cancelled. No one needed an email.',
|
||||
'walk-in': 'They are on this shift. A confirmation email is queued.',
|
||||
attended: 'Marked attended.',
|
||||
'no-show': 'Marked as a no-show.',
|
||||
'attendance-cleared': 'The attendance mark is cleared.',
|
||||
moved: 'They are on this shift. A change email is queued.',
|
||||
generated: 'Weekly shifts for the next three months are on the schedule. Existing shifts were left as they are.',
|
||||
'no-template': 'There is no active weekly template.',
|
||||
|
||||
+1
-46
@@ -88,7 +88,6 @@ export type RosterPerson = {
|
||||
phone: string | null;
|
||||
notes: string | null;
|
||||
status: 'confirmed' | 'cancelled';
|
||||
attendance: 'attended' | 'no-show' | null;
|
||||
};
|
||||
|
||||
export type AdminShift = AdminShiftSummary & {
|
||||
@@ -292,7 +291,7 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
|
||||
if (!row) return null;
|
||||
const people = db
|
||||
.prepare(
|
||||
`SELECT id, name, email, phone, notes, status, attended
|
||||
`SELECT id, name, email, phone, notes, status
|
||||
FROM signups
|
||||
WHERE shift_id = ? AND anonymized_at IS NULL AND name IS NOT NULL AND email IS NOT NULL
|
||||
ORDER BY CASE status WHEN 'confirmed' THEN 0 ELSE 1 END, id`,
|
||||
@@ -304,7 +303,6 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
|
||||
phone: string | null;
|
||||
notes: string | null;
|
||||
status: string;
|
||||
attended: number | null;
|
||||
}>;
|
||||
return {
|
||||
...presentShift(row, row.tz),
|
||||
@@ -321,7 +319,6 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
|
||||
phone: person.phone,
|
||||
notes: person.notes,
|
||||
status: person.status,
|
||||
attendance: person.attended === 1 ? 'attended' : person.attended === 0 ? 'no-show' : null,
|
||||
}];
|
||||
}),
|
||||
};
|
||||
@@ -946,48 +943,6 @@ export function cancelSignupAsCoordinator(
|
||||
}).immediate();
|
||||
}
|
||||
|
||||
export type AttendanceMark = 'attended' | 'no-show' | 'clear';
|
||||
|
||||
export type AttendanceResult =
|
||||
| { ok: true; shiftId: number; already: boolean }
|
||||
| { ok: false; error: string };
|
||||
|
||||
/** Records whether a confirmed person came. It does not change the spot or send email. */
|
||||
export function setAttendance(
|
||||
db: Database.Database,
|
||||
coordinatorId: number,
|
||||
signupId: number,
|
||||
mark: AttendanceMark,
|
||||
now: string,
|
||||
): AttendanceResult {
|
||||
return db.transaction((): AttendanceResult => {
|
||||
const row = db
|
||||
.prepare(
|
||||
`SELECT id AS id, shift_id AS shift_id, status AS status, attended AS attended, anonymized_at AS anonymized_at
|
||||
FROM signups WHERE id = ?`,
|
||||
)
|
||||
.get(signupId) as
|
||||
| { id: number; shift_id: number; status: string; attended: number | null; anonymized_at: string | null }
|
||||
| undefined;
|
||||
if (!row || row.anonymized_at) return { ok: false, error: 'That signup is not available.' };
|
||||
if (row.status !== 'confirmed') return { ok: false, error: 'That signup is cancelled.' };
|
||||
const next = mark === 'attended' ? 1 : mark === 'no-show' ? 0 : null;
|
||||
const current = row.attended === null ? null : Number(row.attended);
|
||||
if (current === next) return { ok: true, shiftId: row.shift_id, already: true };
|
||||
const updated = db
|
||||
.prepare(
|
||||
`UPDATE signups
|
||||
SET attended = ?, updated_at = ?
|
||||
WHERE id = ? AND status = 'confirmed' AND anonymized_at IS NULL`,
|
||||
)
|
||||
.run(next, now, signupId);
|
||||
if (updated.changes !== 1) return { ok: false, error: 'That signup is not available.' };
|
||||
if (next === null) writeAudit(db, coordinatorId, 'signup.attend.clear', { signupId: row.id, shiftId: row.shift_id }, now);
|
||||
else writeAudit(db, coordinatorId, 'signup.attend', { signupId: row.id, shiftId: row.shift_id, attended: next }, now);
|
||||
return { ok: true, shiftId: row.shift_id, already: false };
|
||||
}).immediate();
|
||||
}
|
||||
|
||||
export function findSignupShift(db: Database.Database, signupId: number): number | null {
|
||||
const row = db
|
||||
.prepare('SELECT shift_id AS shift_id FROM signups WHERE id = ? AND anonymized_at IS NULL')
|
||||
|
||||
+2
-2
@@ -144,8 +144,8 @@ function insertFakeSignups(db: Database.Database, shiftId: number, createdAt: st
|
||||
`INSERT INTO signups (
|
||||
shift_id, name, email, email_norm, phone, is_minor, guardian_name, guardian_email,
|
||||
group_size, notes, status, manage_token_hash, token_expires_at, reminders_off,
|
||||
attended, created_at, updated_at, anonymized_at
|
||||
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, NULL, NULL, 0, NULL, ?, ?, NULL)`,
|
||||
created_at, updated_at, anonymized_at
|
||||
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, NULL, NULL, 0, ?, ?, NULL)`,
|
||||
);
|
||||
return people.map((person) =>
|
||||
insertId(
|
||||
|
||||
+1
-4
@@ -18,7 +18,6 @@ const COLUMNS = [
|
||||
'Group size',
|
||||
'Notes',
|
||||
'Status',
|
||||
'Attended',
|
||||
] as const;
|
||||
|
||||
export type RosterExport = { csv: string; rows: number };
|
||||
@@ -34,13 +33,12 @@ type RosterRecord = {
|
||||
group_size: number;
|
||||
notes: string | null;
|
||||
status: string;
|
||||
attended: number | null;
|
||||
anonymized_at: string | null;
|
||||
};
|
||||
|
||||
const ROSTER_SQL = `SELECT s.starts_at_utc AS starts_at_utc, s.ends_at_utc AS ends_at_utc, e.tz AS tz, s.role AS role,
|
||||
su.name AS name, su.email AS email, su.phone AS phone, su.group_size AS group_size,
|
||||
su.notes AS notes, su.status AS status, su.attended AS attended, su.anonymized_at AS anonymized_at
|
||||
su.notes AS notes, su.status AS status, su.anonymized_at AS anonymized_at
|
||||
FROM signups su
|
||||
JOIN shifts s ON s.id = su.shift_id
|
||||
JOIN events e ON e.id = s.event_id`;
|
||||
@@ -131,7 +129,6 @@ function present(row: RosterRecord): string[] {
|
||||
String(row.group_size),
|
||||
row.notes ?? '',
|
||||
row.status === 'cancelled' ? 'Cancelled' : 'Confirmed',
|
||||
row.attended === 1 ? 'Attended' : row.attended === 0 ? 'No-show' : '',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+17
-9
@@ -614,15 +614,7 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {
|
||||
{shift.inProgress ? <p class="status">In progress</p> : null}
|
||||
<Spots shift={shift} />
|
||||
<h4 class="roster-label">Volunteers</h4>
|
||||
{shift.volunteers.length === 0 ? (
|
||||
<p class="roster-empty">No one signed up yet.</p>
|
||||
) : (
|
||||
<ul class="roster-names">
|
||||
{shift.volunteers.map((name, index) => (
|
||||
<li key={`${shift.id}-${index}`}>{name}</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
<RosterNames config={props.config} shiftId={shift.id} names={shift.volunteers} />
|
||||
</div>
|
||||
{shift.full ? (
|
||||
<p class="btn-card is-static">
|
||||
@@ -831,6 +823,22 @@ function CalendarShift(props: { config: AppConfig; shift: PublicShift }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RosterNames(props: { config: AppConfig; shiftId: number; names: string[] }) {
|
||||
if (props.names.length === 0) {
|
||||
return <p class="roster-empty">No one signed up yet.</p>;
|
||||
}
|
||||
return (
|
||||
<ul class="roster-names">
|
||||
{props.names.map((name, index) => (
|
||||
<li key={`${props.shiftId}-${index}`}>
|
||||
<img class="roster-mark" src={asset(props.config, '/img/sunburst.png')} alt="" />
|
||||
<span>{name}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function ShiftWhen(props: { shift: PublicShift }) {
|
||||
const shift = props.shift;
|
||||
return (
|
||||
|
||||
+5
-72
@@ -455,69 +455,6 @@ describe('coordinator screens', () => {
|
||||
expect(count(db, "SELECT COUNT(*) AS n FROM signups WHERE email_norm = 'late@example.invalid'")).toBe(0);
|
||||
});
|
||||
|
||||
it('marks attendance without emailing or showing it publicly', async () => {
|
||||
const { app, db } = await buildApp();
|
||||
const cookie = await signIn(app, db);
|
||||
const shiftId = await openShift(app, cookie, { published: true, capacity: '2', role: 'Greeting', date: '2026-10-22' });
|
||||
const added = await postWalkIn(app, cookie, shiftId, { name: 'Ria Example', email: 'ria.fake@example.invalid' });
|
||||
expect(added.status).toBe(303);
|
||||
const signupId = (db.prepare("SELECT id AS id FROM signups WHERE email_norm = 'ria.fake@example.invalid'").get() as { id: number }).id;
|
||||
const mailBefore = count(db, 'SELECT COUNT(*) AS n FROM outbox');
|
||||
const attended = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'attended' });
|
||||
expect(attended.status).toBe(303);
|
||||
expect(attended.headers.get('location')).toContain('notice=attended');
|
||||
expect(db.prepare('SELECT attended AS attended FROM signups WHERE id = ?').get(signupId)).toEqual({ attended: 1 });
|
||||
expect(count(db, 'SELECT COUNT(*) AS n FROM outbox')).toBe(mailBefore);
|
||||
expect(count(db, "SELECT COUNT(*) AS n FROM audit WHERE action = 'signup.attend'")).toBe(1);
|
||||
const repeat = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'attended' });
|
||||
expect(repeat.status).toBe(303);
|
||||
expect(count(db, "SELECT COUNT(*) AS n FROM audit WHERE action = 'signup.attend'")).toBe(1);
|
||||
const roster = await (await app.request(attended.headers.get('location') ?? '', { headers: { cookie } })).text();
|
||||
expect(roster).toContain('Marked attended.');
|
||||
expect(roster).toContain('Attended.');
|
||||
expect(roster).toContain('aria-pressed="true"');
|
||||
|
||||
const missed = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'no-show' });
|
||||
expect(missed.status).toBe(303);
|
||||
expect(db.prepare('SELECT attended AS attended FROM signups WHERE id = ?').get(signupId)).toEqual({ attended: 0 });
|
||||
const missedPage = await (await app.request(missed.headers.get('location') ?? '', { headers: { cookie } })).text();
|
||||
expect(missedPage).toContain('No-show.');
|
||||
const cleared = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'clear' });
|
||||
expect(cleared.status).toBe(303);
|
||||
expect(db.prepare('SELECT attended AS attended FROM signups WHERE id = ?').get(signupId)).toEqual({ attended: null });
|
||||
expect(count(db, "SELECT COUNT(*) AS n FROM audit WHERE action = 'signup.attend.clear'")).toBe(1);
|
||||
|
||||
const marked = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'attended' });
|
||||
expect(marked.status).toBe(303);
|
||||
const publicShift = await (await app.request(`/s/${shiftId}`)).text();
|
||||
expect(publicShift).not.toContain('ria.fake@example.invalid');
|
||||
expect(publicShift).not.toContain('No-show');
|
||||
expect(publicShift).not.toContain('Attended.');
|
||||
expect(await (await app.request('/')).text()).not.toContain('ria.fake@example.invalid');
|
||||
|
||||
db.prepare("UPDATE shifts SET starts_at_utc = '2026-10-14T14:00:00.000Z', ends_at_utc = '2026-10-14T17:00:00.000Z' WHERE id = ?").run(shiftId);
|
||||
const afterEnd = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'no-show' });
|
||||
expect(afterEnd.status).toBe(303);
|
||||
expect(db.prepare('SELECT attended AS attended FROM signups WHERE id = ?').get(signupId)).toEqual({ attended: 0 });
|
||||
|
||||
await postForm(app, `/admin/signups/${signupId}/cancel`, cookie, {});
|
||||
const blocked = await postForm(app, `/admin/signups/${signupId}/attendance`, cookie, { mark: 'attended' });
|
||||
expect(blocked.status).toBe(400);
|
||||
expect(await blocked.text()).toContain('That signup is cancelled.');
|
||||
expect(db.prepare('SELECT attended AS attended FROM signups WHERE id = ?').get(signupId)).toEqual({ attended: 0 });
|
||||
const closedRoster = await (await app.request(`/admin/shifts/${shiftId}`, { headers: { cookie } })).text();
|
||||
expect(closedRoster).not.toContain(`/admin/signups/${signupId}/attendance`);
|
||||
expect(auditJson(db)).not.toContain('@');
|
||||
|
||||
const bare = await app.request(`/admin/signups/${signupId}/attendance`, {
|
||||
method: 'POST',
|
||||
headers: { origin: ORIGIN, 'content-type': 'application/x-www-form-urlencoded', cookie },
|
||||
body: new URLSearchParams({ mark: 'attended' }),
|
||||
});
|
||||
expect(bare.status).toBe(403);
|
||||
expect(db.prepare('SELECT attended AS attended FROM signups WHERE id = ?').get(signupId)).toEqual({ attended: 0 });
|
||||
});
|
||||
|
||||
it('rejects a coordinator form without its matching token', async () => {
|
||||
const { app, db } = await buildApp();
|
||||
const cookie = await signIn(app, db);
|
||||
@@ -551,7 +488,7 @@ describe('coordinator screens', () => {
|
||||
});
|
||||
expect(added.status).toBe(303);
|
||||
const signupId = signupIdFor(db, 'kim@example.invalid');
|
||||
db.prepare('UPDATE signups SET phone = ?, notes = ?, reminders_off = 1, attended = 1 WHERE id = ?').run('712-555-0199', 'Blue shirt', signupId);
|
||||
db.prepare('UPDATE signups SET phone = ?, notes = ?, reminders_off = 1 WHERE id = ?').run('712-555-0199', 'Blue shirt', signupId);
|
||||
const oldToken = manageToken(db, signupId, 'confirmation');
|
||||
db.prepare(
|
||||
`INSERT INTO outbox (
|
||||
@@ -569,20 +506,18 @@ describe('coordinator screens', () => {
|
||||
expect(moved.status).toBe(303);
|
||||
expect(moved.headers.get('location')).toBe(`/admin/shifts/${destinationId}?notice=moved`);
|
||||
|
||||
const source = db.prepare('SELECT status, attended, shift_id FROM signups WHERE id = ?').get(signupId) as {
|
||||
const source = db.prepare('SELECT status, shift_id FROM signups WHERE id = ?').get(signupId) as {
|
||||
status: string;
|
||||
attended: number;
|
||||
shift_id: number;
|
||||
};
|
||||
expect(source).toEqual({ status: 'cancelled', attended: 1, shift_id: sourceId });
|
||||
expect(source).toEqual({ status: 'cancelled', shift_id: sourceId });
|
||||
expect(readManageSignup(db, oldToken, NOW)).toBeNull();
|
||||
const created = db.prepare(
|
||||
`SELECT id, status, attended, phone, notes, reminders_off, is_minor, guardian_name, guardian_email, shift_id
|
||||
`SELECT id, status, phone, notes, reminders_off, is_minor, guardian_name, guardian_email, shift_id
|
||||
FROM signups WHERE shift_id = ? AND status = 'confirmed'`,
|
||||
).get(destinationId) as {
|
||||
id: number;
|
||||
status: string;
|
||||
attended: number | null;
|
||||
phone: string;
|
||||
notes: string;
|
||||
reminders_off: number;
|
||||
@@ -593,7 +528,6 @@ describe('coordinator screens', () => {
|
||||
};
|
||||
expect(created).toMatchObject({
|
||||
status: 'confirmed',
|
||||
attended: null,
|
||||
phone: '712-555-0199',
|
||||
notes: 'Blue shirt',
|
||||
reminders_off: 1,
|
||||
@@ -625,7 +559,7 @@ describe('coordinator screens', () => {
|
||||
const roster = await (await app.request(moved.headers.get('location') ?? '', { headers: { cookie } })).text();
|
||||
expect(roster).toContain('They are on this shift. A change email is queued.');
|
||||
expect(roster).toContain('Kim Example');
|
||||
expect(roster).toContain('Attendance is not marked.');
|
||||
expect(roster).not.toContain('No-show');
|
||||
const sourceRoster = await (await app.request(`/admin/shifts/${sourceId}`, { headers: { cookie } })).text();
|
||||
expect(sourceRoster).not.toContain(`/admin/signups/${signupId}/move`);
|
||||
expect(sourceRoster).toContain('0/2 spots filled');
|
||||
@@ -636,7 +570,6 @@ describe('coordinator screens', () => {
|
||||
expect(home).not.toContain('Blue shirt');
|
||||
expect(home).toContain('Kim Example');
|
||||
expect(shiftPage).not.toContain('kim@example.invalid');
|
||||
expect(shiftPage).not.toContain('Attended.');
|
||||
expect(auditJson(db)).not.toContain('@');
|
||||
});
|
||||
|
||||
|
||||
@@ -161,7 +161,6 @@ describe('manage-link switch', () => {
|
||||
const destinationId = insertShift(db, eventId, 'Distribution', '2026-10-17T14:00:00.000Z', '2026-10-17T17:00:00.000Z', 2);
|
||||
const { managePath } = await openManage(app, shiftId, 'pat.switch@example.invalid', '203.0.113.40');
|
||||
const signupId = Number((db.prepare('SELECT id AS id FROM signups').get() as { id: number }).id);
|
||||
db.prepare('UPDATE signups SET attended = 1 WHERE id = ?').run(signupId);
|
||||
db.prepare(
|
||||
`INSERT INTO outbox (
|
||||
dedupe_key, signup_id, shift_id, kind, to_email, subject, body_text, body_html,
|
||||
@@ -190,17 +189,15 @@ describe('manage-link switch', () => {
|
||||
expect(nextHtml).toContain('Confirmed');
|
||||
expect(await (await app.request(managePath)).status).toBe(404);
|
||||
|
||||
expect(db.prepare('SELECT status, attended, shift_id FROM signups WHERE id = ?').get(signupId)).toEqual({
|
||||
expect(db.prepare('SELECT status, shift_id FROM signups WHERE id = ?').get(signupId)).toEqual({
|
||||
status: 'cancelled',
|
||||
attended: 1,
|
||||
shift_id: shiftId,
|
||||
});
|
||||
const created = db.prepare("SELECT status, attended, shift_id FROM signups WHERE status = 'confirmed'").get() as {
|
||||
const created = db.prepare("SELECT status, shift_id FROM signups WHERE status = 'confirmed'").get() as {
|
||||
status: string;
|
||||
attended: number | null;
|
||||
shift_id: number;
|
||||
};
|
||||
expect(created).toEqual({ status: 'confirmed', attended: null, shift_id: destinationId });
|
||||
expect(created).toEqual({ status: 'confirmed', shift_id: destinationId });
|
||||
expect(db.prepare("SELECT status FROM outbox WHERE kind = 'confirmation'").get()).toEqual({ status: 'cancelled' });
|
||||
expect(db.prepare("SELECT status FROM outbox WHERE kind = 'reminder'").get()).toEqual({ status: 'cancelled' });
|
||||
expect(db.prepare("SELECT COUNT(*) AS n FROM outbox WHERE kind = 'cancelled'").get()).toEqual({ n: 0 });
|
||||
|
||||
+2
-2
@@ -398,7 +398,7 @@ function insertAnonymized(db: Database.Database, shiftId: number): void {
|
||||
db.prepare(
|
||||
`INSERT INTO signups (
|
||||
shift_id, name, email, email_norm, phone, is_minor, guardian_name, guardian_email, group_size,
|
||||
notes, status, manage_token_hash, token_expires_at, reminders_off, attended, created_at, updated_at, anonymized_at
|
||||
) VALUES (?, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1, NULL, 'confirmed', NULL, NULL, 0, NULL, ?, ?, ?)`,
|
||||
notes, status, manage_token_hash, token_expires_at, reminders_off, created_at, updated_at, anonymized_at
|
||||
) VALUES (?, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1, NULL, 'confirmed', NULL, NULL, 0, ?, ?, ?)`,
|
||||
).run(shiftId, INSTANT, INSTANT, INSTANT);
|
||||
}
|
||||
@@ -34,8 +34,8 @@ describe('roster export', () => {
|
||||
const eventId = insertEvent(db, 'weekly', 'Weekly pantry');
|
||||
const shiftId = insertShift(db, eventId, '2026-10-15T14:00:00.000Z', '2026-10-15T17:00:00.000Z');
|
||||
const other = insertShift(db, eventId, '2026-10-17T14:00:00.000Z', '2026-10-17T17:00:00.000Z');
|
||||
insertSignup(db, shiftId, { name: '=Ada', email: 'ada@example.invalid', notes: 'Blue, shirt', attended: 1 });
|
||||
insertSignup(db, shiftId, { name: 'Ben', email: 'ben@example.invalid', status: 'cancelled', attended: 0 });
|
||||
insertSignup(db, shiftId, { name: '=Ada', email: 'ada@example.invalid', notes: 'Blue, shirt' });
|
||||
insertSignup(db, shiftId, { name: 'Ben', email: 'ben@example.invalid', status: 'cancelled' });
|
||||
insertSignup(db, shiftId, { name: null, email: null, anonymized: true });
|
||||
insertSignup(db, other, { name: 'Cam', email: 'cam@example.invalid' });
|
||||
|
||||
@@ -48,13 +48,12 @@ describe('roster export', () => {
|
||||
expect(text).toContain('"Blue, shirt"');
|
||||
expect(text).toContain('ada@example.invalid');
|
||||
expect(text).toContain('Cancelled');
|
||||
expect(text).toContain('No-show');
|
||||
expect(text).toContain('Attended');
|
||||
expect(text).not.toContain('Attended');
|
||||
expect(text).toContain('2026-10-15');
|
||||
expect(text).toContain('America/Chicago (CDT)');
|
||||
expect(text).not.toContain('cam@example.invalid');
|
||||
expect(text).not.toContain('Cam');
|
||||
const anonymized = text.split('\r\n').find((line) => line.includes(',Confirmed,') && !line.includes('@'));
|
||||
const anonymized = text.split('\r\n').find((line) => line.endsWith(',Confirmed') && !line.includes('@'));
|
||||
expect(anonymized).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -173,7 +172,6 @@ function insertSignup(
|
||||
notes?: string | null;
|
||||
phone?: string | null;
|
||||
status?: string;
|
||||
attended?: number | null;
|
||||
anonymized?: boolean;
|
||||
},
|
||||
): void {
|
||||
@@ -181,8 +179,8 @@ function insertSignup(
|
||||
db.prepare(
|
||||
`INSERT INTO signups (
|
||||
shift_id, name, email, email_norm, phone, is_minor, guardian_name, guardian_email, group_size, notes,
|
||||
status, reminders_off, attended, created_at, updated_at, anonymized_at
|
||||
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, 0, ?, ?, ?, ?)`,
|
||||
status, reminders_off, created_at, updated_at, anonymized_at
|
||||
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, 0, ?, ?, ?)`,
|
||||
).run(
|
||||
shiftId,
|
||||
anonymized ? null : options.name,
|
||||
@@ -191,7 +189,6 @@ function insertSignup(
|
||||
anonymized ? null : options.phone ?? null,
|
||||
anonymized ? null : options.notes ?? null,
|
||||
options.status ?? 'confirmed',
|
||||
options.attended ?? null,
|
||||
NOW,
|
||||
NOW,
|
||||
anonymized ? NOW : null,
|
||||
|
||||
@@ -36,6 +36,7 @@ describe('public pages', () => {
|
||||
expect(html).toContain('Wednesday Sorting');
|
||||
expect(html).toContain('Wednesday Greeting');
|
||||
expect(html).toContain('Lane Wednesday');
|
||||
expect(html).toContain('class="roster-mark" src="/img/sunburst.png?v=');
|
||||
expect(html).toContain('Live Greeting');
|
||||
expect(html).toContain('0/2 spots filled');
|
||||
expect(html).toContain('1/4 spots filled');
|
||||
|
||||
+11
-16
@@ -27,8 +27,8 @@ describe('retention cleanup', () => {
|
||||
const eventId = insertEvent(db, 'pantry', 'America/Chicago');
|
||||
const oldShift = insertShift(db, eventId, '2024-06-01T16:00:00.000Z', '2024-06-01T17:00:00.000Z');
|
||||
const recentShift = insertShift(db, eventId, '2026-06-14T16:00:00.000Z', '2026-06-14T17:00:00.000Z');
|
||||
insertSignup(db, oldShift, 'Old Volunteer', 'old.volunteer@example.invalid', 1, 1);
|
||||
insertSignup(db, recentShift, 'New Volunteer', 'new.volunteer@example.invalid', 0, null);
|
||||
insertSignup(db, oldShift, 'Old Volunteer', 'old.volunteer@example.invalid', 1);
|
||||
insertSignup(db, recentShift, 'New Volunteer', 'new.volunteer@example.invalid', 0);
|
||||
|
||||
const result = runRetention(db, NOW);
|
||||
expect(result.signups).toBe(1);
|
||||
@@ -44,14 +44,12 @@ describe('retention cleanup', () => {
|
||||
notes: null,
|
||||
manage_token_hash: null,
|
||||
status: 'confirmed',
|
||||
attended: 1,
|
||||
anonymized_at: NOW,
|
||||
});
|
||||
expect(signup(db, recentShift).name).toBe('New Volunteer');
|
||||
const csv = exportShiftRoster(db, oldShift)?.csv ?? '';
|
||||
expect(csv).not.toContain('old.volunteer@example.invalid');
|
||||
expect(csv).not.toContain(',No,');
|
||||
expect(csv).toContain('Attended');
|
||||
expect(JSON.stringify(db.prepare('SELECT detail_json AS detail_json FROM audit').all())).not.toContain('@');
|
||||
});
|
||||
|
||||
@@ -61,8 +59,8 @@ describe('retention cleanup', () => {
|
||||
const eventId = insertEvent(db, 'pantry', 'America/Chicago');
|
||||
const dueShift = insertShift(db, eventId, '2026-04-01T16:00:00.000Z', '2026-04-01T17:00:00.000Z');
|
||||
const earlyShift = insertShift(db, eventId, '2026-06-01T16:00:00.000Z', '2026-06-01T17:00:00.000Z');
|
||||
const dueSignup = insertSignup(db, dueShift, 'Due Volunteer', 'due.volunteer@example.invalid', 0, null);
|
||||
insertSignup(db, earlyShift, 'Early Volunteer', 'early.volunteer@example.invalid', 0, null);
|
||||
const dueSignup = insertSignup(db, dueShift, 'Due Volunteer', 'due.volunteer@example.invalid', 0);
|
||||
insertSignup(db, earlyShift, 'Early Volunteer', 'early.volunteer@example.invalid', 0);
|
||||
insertOutbox(db, {
|
||||
dedupe: 'confirmation:v1:due:due.volunteer@example.invalid',
|
||||
signupId: dueSignup,
|
||||
@@ -87,7 +85,7 @@ describe('retention cleanup', () => {
|
||||
const db = await openDb();
|
||||
const eventId = insertEvent(db, 'pantry', 'America/Chicago');
|
||||
const shiftId = insertShift(db, eventId, '2026-06-14T16:00:00.000Z', '2026-06-14T17:00:00.000Z');
|
||||
const signupId = insertSignup(db, shiftId, 'Mail Volunteer', 'mail.volunteer@example.invalid', 0, null);
|
||||
const signupId = insertSignup(db, shiftId, 'Mail Volunteer', 'mail.volunteer@example.invalid', 0);
|
||||
insertOutbox(db, {
|
||||
dedupe: 'confirmation:v1:1:mail.volunteer@example.invalid',
|
||||
signupId,
|
||||
@@ -210,10 +208,10 @@ describe('retention cleanup', () => {
|
||||
const db = await openDb();
|
||||
const eventId = insertEvent(db, 'pantry', 'America/Chicago');
|
||||
const shiftId = insertShift(db, eventId, '2024-06-01T16:00:00.000Z', '2024-06-01T17:00:00.000Z');
|
||||
insertSignup(db, shiftId, 'Clock Volunteer', 'clock.volunteer@example.invalid', 0, null);
|
||||
insertSignup(db, shiftId, 'Clock Volunteer', 'clock.volunteer@example.invalid', 0);
|
||||
const broken = insertEvent(db, 'broken', 'Not/AZone');
|
||||
const brokenShift = insertShift(db, broken, '2024-06-01T16:00:00.000Z', '2024-06-01T17:00:00.000Z');
|
||||
insertSignup(db, brokenShift, 'Broken Volunteer', 'broken.volunteer@example.invalid', 0, null);
|
||||
insertSignup(db, brokenShift, 'Broken Volunteer', 'broken.volunteer@example.invalid', 0);
|
||||
|
||||
expect(runDueRetention(db, BEFORE)).toMatchObject({ ran: false });
|
||||
expect(signup(db, shiftId).name).toBe('Clock Volunteer');
|
||||
@@ -239,7 +237,7 @@ describe('retention cleanup', () => {
|
||||
const fall = await openDb();
|
||||
const fallEvent = insertEvent(fall, 'pantry', 'America/Chicago');
|
||||
const fallShift = insertShift(fall, fallEvent, '2024-06-01T16:00:00.000Z', '2024-06-01T17:00:00.000Z');
|
||||
insertSignup(fall, fallShift, 'Fall Volunteer', 'fall.volunteer@example.invalid', 0, null);
|
||||
insertSignup(fall, fallShift, 'Fall Volunteer', 'fall.volunteer@example.invalid', 0);
|
||||
const firstHour = localUtc('2026-11-01', 1, 0, 'earlier');
|
||||
const secondHour = localUtc('2026-11-01', 1, 30, 'later');
|
||||
expect(runDueRetention(fall, firstHour).ran).toBe(true);
|
||||
@@ -251,7 +249,7 @@ describe('retention cleanup', () => {
|
||||
const db = await openDb();
|
||||
const eventId = insertEvent(db, 'pantry', 'America/Chicago');
|
||||
const shiftId = insertShift(db, eventId, '2024-06-01T16:00:00.000Z', '2024-06-01T17:00:00.000Z');
|
||||
insertSignup(db, shiftId, 'Runner Volunteer', 'runner.volunteer@example.invalid', 0, null);
|
||||
insertSignup(db, shiftId, 'Runner Volunteer', 'runner.volunteer@example.invalid', 0);
|
||||
const runner = startRetentionRunner(db, () => NOW);
|
||||
expect(signup(db, shiftId).name).toBeNull();
|
||||
runner.stop();
|
||||
@@ -304,15 +302,14 @@ function insertSignup(
|
||||
name: string,
|
||||
email: string,
|
||||
isMinor: number,
|
||||
attended: number | null,
|
||||
): number {
|
||||
return Number(
|
||||
db.prepare(
|
||||
`INSERT INTO signups (
|
||||
shift_id, name, email, email_norm, phone, is_minor, guardian_name, guardian_email,
|
||||
group_size, notes, status, manage_token_hash, token_expires_at, reminders_off,
|
||||
attended, created_at, updated_at, anonymized_at
|
||||
) VALUES (?, ?, ?, ?, '555-0100', ?, ?, ?, 1, 'Bring a pen', 'confirmed', ?, ?, 0, ?, ?, ?, NULL)`,
|
||||
created_at, updated_at, anonymized_at
|
||||
) VALUES (?, ?, ?, ?, '555-0100', ?, ?, ?, 1, 'Bring a pen', 'confirmed', ?, ?, 0, ?, ?, NULL)`,
|
||||
).run(
|
||||
shiftId,
|
||||
name,
|
||||
@@ -323,7 +320,6 @@ function insertSignup(
|
||||
isMinor ? 'guardian.pat@example.invalid' : null,
|
||||
`hash-${email}`,
|
||||
'2026-06-20T15:00:00.000Z',
|
||||
attended,
|
||||
NOW,
|
||||
NOW,
|
||||
).lastInsertRowid,
|
||||
@@ -374,7 +370,6 @@ function signup(db: Awaited<ReturnType<typeof openDb>>, shiftId: number) {
|
||||
notes: string | null;
|
||||
manage_token_hash: string | null;
|
||||
status: string;
|
||||
attended: number | null;
|
||||
anonymized_at: string | null;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user