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

WIP: Need to make recurring rides work as a feature; Fixed Schedule so that rides from other days show up. #539

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

namanhboi
Copy link
Contributor

@namanhboi namanhboi commented Oct 16, 2024

Summary

Currently, recurring rides doesn't work at all. It doesn't show up in the scheduled/unscheduled rides table of other days nor does it show up in the big Schedule in the home page.
screen-capture (3).webm

This is because the useRides() function that both the rides table and schedule uses from RidesContext.tsx only pulls from the backend the rides from the current day. Since the recurring rides doesn't exist in the backend, they won't show up in the tables or the schedule.

I plan to add the recurring rides feature by updating scheduledRides and unscheduledRides of RidesContext to have both the normal and recurring rides, which haven't been added to the backend yet. This ensures that these recurring rides show up in the ride tables and schedules. When we need to delete or edit these recurring rides, that's when we communiate with the database.

Additionaly, I also found 2 bugs which I both fixed:

  • The schedule doesn't show rides from days other than the original day.
    Cheese_Wed-16Oct24_03 09
    Here, the ride at the bottom doesn't show up on the schedule
  • Can't edit recurring rides.
    Cheese_Wed-16Oct24_03 09_000
    __I clicked on the edit button of the ride on the bottom, which is a recurring ride, and nothing shows up.

However, I found another bug in the backend that diasbled access to the carriage website which persists on the master branch.
Cheese_Wed-16Oct24_03 14_000
Cheese_Wed-16Oct24_03 14
The origin is here
Cheese_Wed-16Oct24_03 16
This might have been caused by me doing some work in RidesContext.

This pull request is the first step towards making the recurring rides work.

  • added recurring rides to scheduledRides and unscheduledRides of RidesContext . These rides are not in the back end.
  • need to do something about deleting a recurring ride (delete all recurring rides or just that one).
  • need to add a new ride to the backend when you edit a recurring ride
  • fixed the 2 bugs mentioned above

Test Plan

I plan to add recurring rides and manually check if they show up in other days.

Breaking Changes

This bug:
Cheese_Wed-16Oct24_03 14_000
This might have been caused by me doing some work in RidesContext. The master branch now doesn't work?

What has been done:
- fixed the schedule so that rides from other days show up
- unscheduledRides and scheduledRides from useRides of RidesContext now includes recurring rides, however these rides are not in the backend. Then plan is to add them to the backend once you edit/delete them. Edit shouldn't be too hard but delete I need to figure out.
- The Edit button on recurring rides now works
@namanhboi namanhboi requested a review from a team as a code owner October 16, 2024 07:24
@dti-github-bot
Copy link
Member

dti-github-bot commented Oct 16, 2024

[diff-counting] Significant lines: 697.

…e ride which creates a new ride entirely or to edit all recurring rides) and delete (delete that single ride or delete all rides). Lots of bugs: all recurring rides now are unscheduled, also probabaly won't work as a rider
Copy link
Contributor

@raissaji raissaji left a comment

Choose a reason for hiding this comment

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

Hi Nam, great job noticing the bugs! When I pulled your branch, I am coming across an error 500—I took a look at the server log and it appears that the problem lies in your get request const ridesDataToday: Ride[] = await axios in RidesContext. I left a more specific comment in the file that could help you with debugging.

Because of the AxioError, I couldn't add a ride to test how you squashed the bugs.

frontend/src/context/RidesContext.tsx Outdated Show resolved Hide resolved
@namanhboi
Copy link
Contributor Author

namanhboi commented Oct 28, 2024

Ride type:

export type RideType = {
 id: string;
 type: Type;
 status: Status;
 late: boolean;
 startLocation: RideLocation;
 endLocation: RideLocation;
 startTime: string;
 endTime: string;
 rider: RiderType;
 driver?: DriverType;
 recurring: boolean;
 recurringDays?: number[];
 endDate?: string;
 deleted?: string[];
 edits?: string[];
 sourceRide? : RideType;
 immediateParentRide?: RideType;
 children? : RideType;
 sourceRideId? : string;
 immediateParentRideId? : string;
 childrenId? : string;
};

Recurring rides design:

  • sourceRide: the root of the recurring ride tree.
  • immediateParentRide: the immediate parent ride of the current recurring ride.
  • childrenRide: the singular children recurring ride of the current ride.

useRides()

  • all recurring rides returned from useRides() are ride objects: all rides object with recurring = true has immediateParentId and sourceRideId that is not null (they all link to some ride in the db).

Add and Edit design:

3 options to edit:

  1. edit all :
  • Go to the source ride, delete all children ride by recursing down the children’s id.
  • apply edit to original
  • refreshRides
  1. edit from now:
  • Note that we need to lock the date in the edit modal since its from now.![][image1]
  • trim the end date of the immediate parent to before today
  • go down the tree of all children rides and delete all of them
  • create a new ride with the edited data which has the immediateParentRide and immediateParentRideId be from the immediate parent
  • Add that ride to the immediate parent’s childrenRide and childrenRideId.
  • refreshRides
  1. edit a single ride:
  • Note: should also lock the date for simplicity.
  • trim end date of immediate parent to before this day.
  • add a new ride with the edited data on that date with immediateParent and immediateParentId being from the immediate parent.
  • The children of the immediate parent is this ride.
  • create a new recurring ride on the date + 1 with data similar to parent if the parent’s endTime allow for it. Add the id of the parent ride as the id of the newly created ride.
  • refreshRides

3 options to delete:

  1. delete all:
  • go to source ride, delete itself and all children rides
  • refreshRides
  1. delete from now until end date of current ride
  • go to parent ride, trim end date to before today, delete all children rides
  • refreshRides
  1. delete this single ride:
  • trim end date of immediate parent to before this day.
  • delete all children rides of the immediate parent.
  • create a new ride on the date + 1 with data similar to parent if the parent’s endTime allow for it. Add the id of the parent ride as the id of this ride’s parentId.
  • refreshRides

@namanhboi
Copy link
Contributor Author

This ride causes error on the server side because the rider is a name instead of an id to a driver object in Dynamo.
Cheese_Wed-30Oct24_15 42

Gotta be mindful of this when creating recurring rides.

…ing rides, but deleting is still an issue because updating childRideId everytime an axios.put or axios.post is called is wrong
…editing a single ride in a chain of recurring rides, but encountered Invalid UpdateExpression: Two document paths overlap with each other; must remove or rewrite one of these paths; path one: [driver], path two: [parentRideId]
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