Skip to content

Conversation

fox-58
Copy link

@fox-58 fox-58 commented Jul 3, 2025

Description 🧾

Context of PR, summary of changes, as well as any relevant technical decisions/motivations.

Testing

Replace this line with instructions on how to test your changes, as well as any relevant images for UI changes.

Checklist

  • 📍 You have assigned yourself to this pull request.
  • 🔗 You have linked an issue to which this pull request closes.
  • 💭 Leave any relevant specific directions to reviewers.
  • 👀 No secrets in clear text in the pull request.
  • 🎟️ To categorise release notes, the pull request should be labelled with at least one of these labels:
    • feature: for application feature improvement or new features
    • bug: fixing something that previously wasn't working
    • dev: development-side related changes
    • docker: updates to the Docker code
    • setup: changes to the setup/infrastructure of the codebase
    • test: updates to internal testing

@fox-58 fox-58 requested a review from a team as a code owner July 3, 2025 05:12
@fox-58 fox-58 changed the base branch from dev to server-rewrite July 3, 2025 05:13
@Param('timetableId') timetableId: string
) {
try {
const eventDetails = await this.userService.getEvent(eventId, timetableId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just directly return the awaited value here, no need for variable.

@@ -64,4 +66,79 @@ export class UserService {
},
});
}

async getEvent(eventId: string, timetableId: string): Promise<EventParameters | null> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What cases does this promise actually return null? If this is explicitly for the case when you throw an error, that isn't really the way to indicate that. (I'd just remove the null in that case.)

await this.prisma.event.create({
data: {
id: eventParameters.id,
colour: eventParameters.colour,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to change this to use @jason4193's colour validation function once it's merged.

id: eventParameters.id,
colour: eventParameters.colour,
dayOfWeek: eventParameters.dayOfWeek,
start: eventParameters.start,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need some validation on these... Might be worth checking FE code/discussing what we think makes sense to represent event times.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to hold the validation after combining #1000 into server-rewrite branch?

})
}

async removeEvent(eventId: string, timetableId: string): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if it makes sense to omit the timetableId field on all of these routes. The eventId is already unique across all users, across all timetables. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on using eventID directly.

Comment on lines +21 to +29
export class EventParameters {
id: string;
colour: string;
dayOfWeek: number;
start: number;
end: number;
type: EventType;
timetableId: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to obtain everything about the event from prisma. Since only prisma db contains the details of the event that being used on FE.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean importing from server/src/generated/prisma/models/Event.ts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the /generated/ dir is auto generated from the schema. Not sure can we simply import it from that file. What I am thinking is having a duplicate type in here but with all most of the detail in our schema as all the information of the event will be displayed on FE.


@Get('event/:timetableId/:eventId')
@UseGuards(AuthenticatedGuard)
async getEventById(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need an additional function for getting all events'ID by using timetableID. Right now the FE is not holding any information about the Event.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative solution could be return EventID to FE after creating a new event. Then FE storing it as id attribute?

Thoughts on which way better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the required event information should come from the get timetable route. This may already be covered in #1023. Once the frontend is updated though, it may be beneficial from a performance viewpoint to add a route that gets all events from one timetable... 🤔 (Problem for later)

id: eventParameters.id,
colour: eventParameters.colour,
dayOfWeek: eventParameters.dayOfWeek,
start: eventParameters.start,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to hold the validation after combining #1000 into server-rewrite branch?

})
}

async removeEvent(eventId: string, timetableId: string): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on using eventID directly.

@lhvy lhvy mentioned this pull request Jul 10, 2025
@lhvy lhvy force-pushed the server-rewrite branch from 39e1bdd to 599672e Compare July 15, 2025 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants