-
Notifications
You must be signed in to change notification settings - Fork 2
Add feature: For cancelled event won't ping for chanel #82
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
Conversation
|
Please refer to the repo's CONTRIBUTING.md for details on contributing to minerva, e.g. making feature branches and testing your functionality in the development Slack/GCal. You should ideally not be committing to the development branch directly as you'll be triggering a broken deploy every time you commit to your feature until it's complete.
What did you change? I don't see any changes to it in this PR and they already exist in there anyway. |
src/classes/CalendarEvent.ts
Outdated
| throw new Error("Event summary is undefined"); | ||
| } | ||
| const title = event.summary; | ||
| const cancelled = title.includes("CANCELLED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
- This should probably be case-insensitive? If not, be sure to explicitly mention it in the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! This should be case-sensitive by behavior requested :) (But nice checking)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should switch to case-insensitve which seems make more sense. Thanks for reminding this!
src/classes/CalendarEvent.ts
Outdated
|
|
||
| parsedEvent.location = event.location ?? undefined; | ||
| parsedEvent.url = event.htmlLink ?? undefined; | ||
| parsedEvent.cancelled = cancelled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use the constructor to pass the cancelled status instead (see Line 69)
- This might be good to do for
locationandurlas well, unless there isn't a good reason to do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This is a good idea! I switch to use constructor with is_cancelled.
- I didn't change
locationandurl, not sure if other behavior on it.
| "updated": "2023-12-07T15:33:49.949Z", | ||
| "location": "The Bay", | ||
| "summary": "Minerva Testing", | ||
| "summary": "[CANCELLED] Minerva Testing", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment re: unittesting
| const calendarEvent = CalendarEvent.fromGoogleCalendarEvent(googleCalendarEvent, slackChannels); | ||
| expect(calendarEvent).toEqual({ | ||
| title: googleCalendarEvent.summary, | ||
| cancelled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment re: unittesting
| const calendarEvent = CalendarEvent.fromGoogleCalendarEvent(calendarEventJson, slackChannels); | ||
| expect(calendarEvent).toEqual({ | ||
| title: googleCalendarEvent.summary, | ||
| cancelled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment re: unittesting
| expect(parseEvents(googleCalendarEvents, slackChannels)).toEqual([ | ||
| { | ||
| title: googleCalendarEvent.summary, | ||
| cancelled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment re: unittesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of my review comments magically disappeared. See below.
| "updated": "2023-12-07T15:33:49.949Z", | ||
| "location": "The Bay", | ||
| "summary": "Minerva Testing", | ||
| "summary": "[CANCELLED] Minerva Testing", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shoud add more unittests to test the cancelled functionality instead of modifying existing ones to test it. Additionally, refrain from modifying the test fixture like this and change the summary to your liking from within the unittest (e.g. calendarEventJson.summary = "[CANCELLED] Minerva Testing" in whatever unittest tests the cancel functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Thanks! I am not familiar with this project. Defiantly I will make more test on this project 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
|
Please also update the Documentation for this feature as well. |
…d logic and tests
Enhance from dev branch PR for Cancelled Function
|
Thanks for your detailed review :) I did fix everything, please double check before we merge this to production environment |
QuantumManiac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM so far. Just one more thing that might be nice to have.
Add Cancelled Text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some fixing to the wording to the reminder message and you should be good to go.
EDIT: It seems that my code suggestion decided not to be included in the review. See below instead.
The wording still seems a bit awkward when you just append "has been cancelled" to generateEventReminderChannelText. How about:
export function generateEventReminderChannelText(event: CalendarEvent, reminderType: EventReminderType): string {
let message = `${
!event.is_cancelled &&
(reminderType == EventReminderType.FIVE_MINUTES || reminderType == EventReminderType.MANUAL_PING)
? "<!channel>\n"
: ""
}Reminder: *${event.title}*`;
let timeUntilEventMessage: string;
if (reminderType === EventReminderType.FIVE_MINUTES) {
const timeUntilEvent = event.start.getTime() - new Date().getTime();
timeUntilEventMessage = ` in *${Math.ceil(timeUntilEvent / 1000 / 60)} minutes*`;
} else {
timeUntilEventMessage = ` at *${moment(event.start).tz("America/Toronto").format("MMMM Do, YYYY [at] h:mm A")}*`;
}
if (event.is_cancelled) {
message += ` that was supposed to occur ${timeUntilEventMessage} *has been cancelled*`;
} else {
message += ` is occurring ${timeUntilEventMessage}`;
}
...refactor: simplify event reminder message construction
QuantumManiac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Thanks so much for your review :) |
This pull request introduces several enhancements and new features to the Minerva project, including updates to documentation, additions to the
CalendarEventclass, and improvements to event reminders. The most important changes include adding a cancelled status to calendar events, updating the README file with usage and development guides, and modifying event reminders to account for cancelled events.Documentation Updates:
README.md: Added links to usage guides and development onboarding and reference guides for Minerva.CalendarEvent Class Enhancements:
src/classes/CalendarEvent.ts: Added acancelledproperty to theCalendarEventclass to indicate if an event is cancelled. [1] [2] [3]Event Reminder Improvements:
src/utils/eventReminders.ts: Modified thegenerateEventReminderChannelTextfunction to exclude reminders for cancelled events.Test Updates:
tests/fixtures/googleCalendarEvent.json: Updated test fixture to include a cancelled event.tests/fixtures/googleCalendarEvents.json: Updated test fixture to include a cancelled event.tests/unit/classes/CalendarEvent.test.ts: Added tests to verify the handling of cancelled events in theCalendarEventclass. [1] [2]tests/unit/utils/googleCalendar.test.ts: Added tests to verify the parsing of cancelled events.This change is