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

Add linkedEvent column to OrderPickupEvent Table #385

Merged
merged 12 commits into from
Jan 20, 2024

Conversation

nik-dange
Copy link
Member

Description

Need a way to tie order pickup events to real events so that frontend can display things like the event graphic

Changes

  • Added a column to OrderPickupEvents table to link to Events
  • Added an accompanying relation

Type of Change

  • Patch (non-breaking change/bugfix)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to not work as
    expected)
  • Documentation (A change to a README/description)
  • Continuous Integration/DevOps Change (Related to deployment steps, continuous integration
    workflows, linting, etc.)
  • Other: (Fill In)

If you've selected Patch, Minor, or Major as your change type, make sure to bump the version before merging in package.json!

Testing

I have tested that my changes fully resolve the linked issue ...

  • locally.
  • on the testing API/testing database.
  • with appropriate Postman routes. Screenshots are included below.

Checklist

  • I have performed a self-review of my own code.
  • I have followed the style guidelines of this project.
  • I have appropriately edited the API version in the package.json file.
  • My changes produce no new warnings.

Screenshots

Please include a screenshot of your Postman testing passing successfully.

Copy link

github-actions bot commented Jan 4, 2024

Thanks for contributing!
If you've made changes to the API's functionality, please make sure to bump the package
version—see this guide to semantic versioning for details—and
document those changes as appropriate.

@nik-dange
Copy link
Member Author

I do api change tmrw I am sleepy

@@ -110,6 +110,7 @@ export class MerchFactory {
orderLimit: FactoryUtils.getRandomNumber(1, 5),
status: OrderPickupEventStatus.ACTIVE,
orders: [],
linkedEvent: null,
Copy link
Member Author

Choose a reason for hiding this comment

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

Should I import the EventFactory and generate an actual dummy event to put in here? Are there any other test cases that could be beneficial for this feature?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't actually think so. I actually don't think it is clean to attach a dummy event everytime we mock a pickupEvent as sometimes pickupEvent doesn't have an actual linkedEvent attached.

I don't believe it is necessary to implement a solution for this now, but for future reference, if there is a new feature that actually depends on linkedEvent, we should come up with a nice way (such as taking an optional boolean flag variable to attach event) to attach dummy linkedEvent to the mocked pickupEvent.

Comment on lines +33 to +36
@OneToOne((type) => EventModel, { nullable: true })
@JoinColumn({ name: 'linkedEvent' })
linkedEvent: EventModel;

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you double check this relation–I found a few different syntax examples online but I believe this establishes the correct one-way relation.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good to me.

@nik-dange nik-dange marked this pull request as ready for review January 11, 2024 06:19
Copy link
Contributor

@dowhep dowhep left a comment

Choose a reason for hiding this comment

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

A few nits. Remember to attach postman screenshots.


if (changes.linkedEventUuid) {
const linkedRegularEvent = await this.getLinkedRegularEvent(changes.linkedEventUuid);
updatedPickupEvent.linkedEvent = linkedRegularEvent;
Copy link
Contributor

Choose a reason for hiding this comment

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

u should save the event into the repository after editing the linkedEvent

Copy link
Contributor

Choose a reason for hiding this comment

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

lets also create a unit test to test for this

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is called when a pickup event is edited, so only the UUID of the linkedEvent would be changed. I made a call to the upsert function on line 1076, which should be the only call necessary to save this change, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh yeah you are right about that

@@ -110,6 +110,7 @@ export class MerchFactory {
orderLimit: FactoryUtils.getRandomNumber(1, 5),
status: OrderPickupEventStatus.ACTIVE,
orders: [],
linkedEvent: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't actually think so. I actually don't think it is clean to attach a dummy event everytime we mock a pickupEvent as sometimes pickupEvent doesn't have an actual linkedEvent attached.

I don't believe it is necessary to implement a solution for this now, but for future reference, if there is a new feature that actually depends on linkedEvent, we should come up with a nice way (such as taking an optional boolean flag variable to attach event) to attach dummy linkedEvent to the mocked pickupEvent.

Comment on lines +33 to +36
@OneToOne((type) => EventModel, { nullable: true })
@JoinColumn({ name: 'linkedEvent' })
linkedEvent: EventModel;

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good to me.

@nik-dange
Copy link
Member Author

Screenshot 2024-01-15 at 3 28 25 PM Screenshot 2024-01-15 at 3 20 04 PM Screenshot 2024-01-15 at 3 06 00 PM

Copy link
Contributor

@dowhep dowhep left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 🚀 🚀 🚀 🚀


if (changes.linkedEventUuid) {
const linkedRegularEvent = await this.getLinkedRegularEvent(changes.linkedEventUuid);
updatedPickupEvent.linkedEvent = linkedRegularEvent;
Copy link
Contributor

Choose a reason for hiding this comment

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

oh yeah you are right about that

@nik-dange nik-dange merged commit 65cd022 into master Jan 20, 2024
5 checks passed
@nik-dange nik-dange deleted the feature/linked-event-column branch February 29, 2024 21:17
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.

2 participants