Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add terms to custom events #1098

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Slo1k
Copy link
Contributor

@Slo1k Slo1k commented Jan 1, 2025

Summary

The change addresses the issue of assigning a term to a custom event when it is created. Previously, when users created custom events, no term was assigned to them. With this update, we now ensure that each custom event is associated with a term.

The term is obtained from the associated ScheduleCourse in the schedule. If the schedule contains classes from multiple terms (e.g., Fall 2023 and Spring 2023), the latest term is selected. If no term is found in the schedule, the default term will be used.

Test Plan

  1. Test creation of a custom event with a single term in the schedule. Verify that the custom event is assigned the correct term.
  2. Test creation of a custom event with multiple terms in the schedule. Ensure the latest term is assigned to the custom event.
  3. Test creation of a custom event with no associated terms in the schedule. Verify that the default term is applied.
  4. Ensure that edge cases like missing terms or incorrect term names in the schedule are handled correctly and fall back to the default term.
  5. Verify that custom events are correctly displayed with their respective terms in calendar view - CustomEventDialog.
  6. Test that after removing some scheduleCourses, the correct term is still assigned to the custom event, reflecting the updated state of the schedule.

Issues

Closes #762

@Slo1k
Copy link
Contributor Author

Slo1k commented Jan 2, 2025

@MinhxNguyen7 Hi! Could you review this pull request when you have a moment? Thanks!

Copy link
Member

@MinhxNguyen7 MinhxNguyen7 left a comment

Choose a reason for hiding this comment

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

Looks alright on the front-end with a minor suggestion.

However, you need to implement the backend to save it as well. For that, you need to add the term to the DB schema and save/get it from the backend endpoints. You can find the custom event schema in apps/backend/src/db/schema/schedule/custom_event.ts. For saving and retrieving, edit getGuestUserData and upsertGetUserData. There's not that much to change, but you'll need to read the code to see what has already been inferred when you changed RepeatingCustomEventSchema. Let me know if you need help with that.

That highlights the fact that the test plan above needs to account for saving and loading user account as well.

@Slo1k
Copy link
Contributor Author

Slo1k commented Jan 7, 2025

Thanks for the feedback!

I’ve made the changes on the frontend as suggested and also tried to adapt the backend by adding the term to the DB schema and updating the relevant endpoints (getGuestUserData and upsertGuestUserData). However, I’m having trouble running the backend locally to verify if the migration with the new field works correctly.

This is my first time working with tRPC, so I’m not entirely sure how to properly set up my local environment for the backend. Could you either check the changes on your side or provide a detailed explanation of how to configure the backend locally to ensure everything works as expected?

Thanks in advance!

@MinhxNguyen7
Copy link
Member

I'll check the changes on my side, and I'm working on updating the README to reflect our stack after a recent migration.

Sorry for the inconvenience. I didn't think about this when I marked the issue as a good first task.

@MinhxNguyen7
Copy link
Member

@Slo1k You can refer to the information added in #1110 to set up locally, if you'd like. I'll try to get reviewing and testing this locally as soon as I can

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.

Download ICS: Assign CourseEvent term to CustomEvent
2 participants