Skip to content

Commit bb2bb36

Browse files
committed
#55 Record last_modified for events
1 parent 827f315 commit bb2bb36

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

back-end/routes/v1/event.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ export default function register(router: Router) {
9191
return [null, Status.Unauthorized]
9292
}
9393

94-
const updatedEvent = (await db.updateTable('event', event, [[
95-
'event_id',
96-
'=',
97-
event_id,
98-
]]))[0]
94+
await db.updateTable('event',
95+
{
96+
...event,
97+
last_modified: new Date().toISOString() as unknown as Date // we need a string to preserve the timezone
98+
},
99+
[['event_id', '=', event_id]]
100+
)
99101

100102
return [null, Status.OK]
101103
} else {
@@ -127,9 +129,10 @@ export default function register(router: Router) {
127129
}
128130
}
129131

130-
const createdEvent = await db.insertTable('event', {
132+
await db.insertTable('event', {
131133
...event,
132134
created_by_account_id: account_id,
135+
last_modified: new Date().toISOString() as unknown as Date // we need a string to preserve the timezone
133136
})
134137

135138
return [null, Status.OK]

back-end/types/db-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export type Tables = {
162162
event_id: event__event_id_Type,
163163
event_site_location: Tables['event_site']['event_site_id'] | null,
164164
event_type: Tables['event_type']['event_type_id'],
165+
last_modified: Date | null,
165166
name: string,
166167
plaintext_location: string | null,
167168
start_datetime: Date,
@@ -291,7 +292,7 @@ export const TABLE_COLUMNS = {
291292
cabin: ["cabin_id","festival_site_id","max_occupancy","name","nickname","notes"],
292293
diet: ["description","diet_id"],
293294
discount: ["discount_code","discount_id","price_multiplier","purchase_type_id"],
294-
event: ["created_by_account_id","description","end_datetime","event_id","event_site_location","event_type","name","plaintext_location","start_datetime","will_be_filmed"],
295+
event: ["created_by_account_id","description","end_datetime","event_id","event_site_location","event_type","last_modified","name","plaintext_location","start_datetime","will_be_filmed"],
295296
event_bookmark: ["account_id","event_id"],
296297
event_site: ["can_host_multiple_events","description","equipment","event_site_id","festival_site_id","location","name","people_cap","structure_type","theme"],
297298
event_type: ["event_type_id"],

0 commit comments

Comments
 (0)