Check for calendar updates after callbacks from Google#20156
Check for calendar updates after callbacks from Google#20156
Conversation
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types
928268c to
11f8cd2
Compare
8b6c6ec to
119665c
Compare
67b2a55 to
b129369
Compare
c82cf43 to
d184869
Compare
lucasmrod
left a comment
There was a problem hiding this comment.
LGTM!
Left a couple of questions to under stand some of the changes before approving.
We should let the product team know that this new feature happens for new events, right?
|
|
||
| func Up_20240626195531(tx *sql.Tx) error { | ||
| if _, err := tx.Exec(`ALTER TABLE calendar_events ADD COLUMN timezone VARCHAR(64) NULL`); err != nil { | ||
| if _, err := tx.Exec(`ALTER TABLE calendar_events ADD COLUMN timezone VARCHAR(64) COLLATE utf8mb4_unicode_ci NULL`); err != nil { |
There was a problem hiding this comment.
This migration wasn't released yet, right?
There was a problem hiding this comment.
(And thanks for catching this!)
| func Up_20240707134035(tx *sql.Tx) error { | ||
| // UUID is a 36-character string with the most common 8-4-4-4-12 format, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
| // Reference: https://en.wikipedia.org/wiki/Universally_unique_identifier#Textual_representation | ||
| if _, err := tx.Exec(`ALTER TABLE calendar_events ADD COLUMN uuid VARCHAR(36) COLLATE utf8mb4_unicode_ci NOT NULL`); err != nil { |
There was a problem hiding this comment.
We use UUID v4, the entirely random version of UUIDs. Such randomness make writes expensive (rebalancing
B+ trees on random-value writes is expensive). See https://planetscale.com/blog/the-problem-with-using-a-uuid-primary-key-in-mysql. That said, it is maybe a-ok for now as this is not a heavy used table like hosts.
Maybe an optimization for later: we could use BINARY(16); see https://dev.mysql.com/blog-archive/storing-uuid-values-in-mysql-tables/
There was a problem hiding this comment.
This makes sense. I'll try to get this optimization in before the release.
| team1Policy1Calendar.ID: ptr.Bool(true), | ||
| team1Policy2.ID: ptr.Bool(false), |
There was a problem hiding this comment.
Curious why you are changing from team2 to team1.
There was a problem hiding this comment.
This looked like a copy/paste error -- I think it was supposed to be team1 initially.
| }, | ||
| ) | ||
| require.NoError(t, err) | ||
| team1Policy2, err := s.ds.NewTeamPolicy( |
There was a problem hiding this comment.
Rename to team1Policy2Calendar? (has CalendarEventsEnabled : true), or set CalendarEventsEnabled: false
There was a problem hiding this comment.
Ok, will make the change for the next PR.
| // Apply current migration. | ||
| applyNext(t, db) | ||
|
|
||
| // check that it's NULL |
There was a problem hiding this comment.
Yes, will fix in the next PR
…20277) #19352 Fix for code review comment: #20156 (comment) Also includes changes from #20252 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality
…20277) #19352 Fix for code review comment: #20156 (comment) Also includes changes from #20252 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality (cherry picked from commit 7bcd61a)
#19352
Video explaining code changes: https://www.loom.com/share/370200a276b84aa388effd6ebd762e01?sid=038508c4-f3c2-40c0-baf6-6b6df682d1f0
In maintenance windows using Google Calendar, calendar event is now recreated within 30 seconds if deleted or moved to the past.
/api/_version_/fleet/calendar/webhook/{event_uuid}calendar_eventstable to make webhook lookup more efficientChecklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements)COLLATE utf8mb4_unicode_ci).