Skip to content

Commit

Permalink
Merge branch 'master' into Update-member-google-sheet-action-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffplays2005 authored Oct 6, 2024
2 parents a30a623 + 90cbf98 commit 010b0eb
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 52 deletions.
28 changes: 19 additions & 9 deletions client/src/models/__generated__/schema.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions server/src/data-layer/models/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,30 +173,37 @@ export interface Event {
/**
* The location of this event
*/
location: string
location?: string

/**
* A URL to the google form for signing up to the event. This is not to be included
* in any response body unless we are _near_ the period for sign up
*/
google_forms_link?: string

/**
* The signup period start date.
* Note that this date is in UTC time.
* Use the same start and end date to indicate a 1 day signup period.
*/
start_date: Timestamp
sign_up_start_date: Timestamp

/**
* The signup period end date.
* Note that this date is in UTC time.
*/
end_date: Timestamp
sign_up_end_date?: Timestamp

/**
* Event start date for the event i.e the day members should meet at shads,
* **NOT** the signups, refer to {@link start_date} for signup start
* **NOT** the signups, refer to {@link sign_up_start_date} for signup start
*/
physical_start_date: Timestamp

/**
* Event end time for the event i.e the last day members will be at the lodge,
* is optionial in case of one day events. **NOT** the signups, refer to
* {@link end_date} for signup end date
* {@link sign_up_end_date} for signup end date
*/
physical_end_date?: Timestamp

Expand Down
28 changes: 18 additions & 10 deletions server/src/data-layer/services/EventService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ const event1: Event = {
description: "Grand opening of the website.",
location: "Virtual pizza event",
physical_start_date: startTimestamp,
start_date: startTimestamp,
end_date: endTimestamp
sign_up_start_date: startTimestamp,
sign_up_end_date: endTimestamp
}
const event2: Event = {
title: "Snowboard racing",
description: "Race and see who's the fastest!",
location: "Snowsport club",
physical_start_date: startTimestamp,
start_date: startTimestamp,
end_date: endTimestamp
sign_up_start_date: startTimestamp,
sign_up_end_date: endTimestamp
}
const now = new Date(Date.now())
const futureEvent: Event = {
Expand All @@ -40,8 +40,10 @@ const futureEvent: Event = {
physical_start_date: Timestamp.fromDate(
new Date(now.getUTCFullYear() + 1, 1, 1)
),
start_date: Timestamp.fromDate(new Date(now.getUTCFullYear() + 1, 1, 1)),
end_date: Timestamp.fromDate(new Date(now.getUTCFullYear() + 1, 1, 1))
sign_up_start_date: Timestamp.fromDate(
new Date(now.getUTCFullYear() + 1, 1, 1)
),
sign_up_end_date: Timestamp.fromDate(new Date(now.getUTCFullYear() + 1, 1, 1))
}

const reservation1: EventReservation = {
Expand Down Expand Up @@ -102,8 +104,10 @@ describe("EventService integration tests", () => {

expect({
...data,
end_date: removeUnderscoresFromTimestamp(data.end_date),
start_date: removeUnderscoresFromTimestamp(data.start_date)
sign_up_end_date: removeUnderscoresFromTimestamp(data.sign_up_end_date),
sign_up_start_date: removeUnderscoresFromTimestamp(
data.sign_up_start_date
)
}).toEqual(event1)
})

Expand All @@ -114,8 +118,12 @@ describe("EventService integration tests", () => {

expect({
...fetchedEvent,
end_date: removeUnderscoresFromTimestamp(fetchedEvent.end_date),
start_date: removeUnderscoresFromTimestamp(fetchedEvent.start_date)
sign_up_end_date: removeUnderscoresFromTimestamp(
fetchedEvent.sign_up_end_date
),
sign_up_start_date: removeUnderscoresFromTimestamp(
fetchedEvent.sign_up_start_date
)
}).toEqual(event1)
})

Expand Down
2 changes: 1 addition & 1 deletion server/src/data-layer/services/EventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EventService {
const now = new Date(Date.now())

const result = await FirestoreCollections.events
.where("end_date", ">", now) // Only get events that have not ended
.where("sign_up_end_date", ">", now) // Only get events that have not ended
.get()

return result.docs.map((doc) => {
Expand Down
9 changes: 5 additions & 4 deletions server/src/middleware/__generated__/routes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions server/src/middleware/__generated__/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/src/middleware/tests/AdminController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@ describe("AdminController endpoint tests", () => {
title: "UASC New event",
physical_start_date: dateToFirestoreTimeStamp(new Date()),
location: "UASC",
start_date: dateToFirestoreTimeStamp(new Date()),
end_date: dateToFirestoreTimeStamp(new Date())
sign_up_start_date: dateToFirestoreTimeStamp(new Date()),
sign_up_end_date: dateToFirestoreTimeStamp(new Date())
}
const eventService = new EventService()

Expand Down
8 changes: 4 additions & 4 deletions server/src/middleware/tests/EventController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const event1: Event = {
title: "UASC New event",
location: "UASC",
physical_start_date: earlierStartDate,
start_date: earlierStartDate,
end_date: earlierStartDate
sign_up_start_date: earlierStartDate,
sign_up_end_date: earlierStartDate
}

/**
Expand All @@ -24,8 +24,8 @@ const event2: Event = {
title: "Straight Zhao",
location: "UASC",
physical_start_date: startDate,
start_date: startDate,
end_date: endDate
sign_up_start_date: startDate,
sign_up_end_date: endDate
}
const reservation1: Omit<EventReservation, "timestamp"> = {
first_name: "John",
Expand Down
12 changes: 6 additions & 6 deletions server/src/service-layer/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,13 +705,13 @@ export class AdminController extends Controller {
const eventService = new EventService()
await eventService.createEvent({
...body.data,
start_date: new Timestamp(
body.data.start_date.seconds,
body.data.start_date.nanoseconds
sign_up_start_date: new Timestamp(
body.data.sign_up_start_date.seconds,
body.data.sign_up_start_date.nanoseconds
),
end_date: new Timestamp(
body.data.end_date.seconds,
body.data.end_date.nanoseconds
sign_up_end_date: new Timestamp(
body.data.sign_up_end_date.seconds,
body.data.sign_up_end_date.nanoseconds
),
physical_start_date: new Timestamp(
body.data.physical_start_date.seconds,
Expand Down

0 comments on commit 010b0eb

Please sign in to comment.