Merged
Conversation
Dschoordsch
commented
Mar 13, 2025
Contributor
Author
Dschoordsch
left a comment
There was a problem hiding this comment.
I'm not sure solving this in code is the right call for the tms field as it's used in the connection logic which should be kept lean.
I'm thinking about making a UserWithTeams view for this use case.
packages/client/modules/userDashboard/components/UserTasksHeader/UserTasksHeader.tsx
Outdated
Show resolved
Hide resolved
Contributor
Author
|
Views are clunky when altering the underlying table. We can achieve the same with just a custom loader. |
b1f681c to
3099ba3
Compare
mattkrick
reviewed
Mar 18, 2025
packages/server/postgres/migrations/2025-03-18T15:55:35.723Z_normalizeUserTms.ts
Outdated
Show resolved
Hide resolved
packages/server/postgres/migrations/2025-03-18T15:55:35.723Z_normalizeUserTms.ts
Outdated
Show resolved
Hide resolved
packages/server/postgres/migrations/2025-03-18T15:55:35.723Z_normalizeUserTms.ts
Outdated
Show resolved
Hide resolved
mattkrick
reviewed
Mar 18, 2025
User.tms must reflect User<-TeamMember->Team relation considering Team.isArchived and TeamMember.isNotRemoved. We query it always with the User and thus it's sensible to keep it in the User. To keep it consistent, we're updating it with triggers now.
898ee9d to
2854b82
Compare
Dschoordsch
commented
Jun 27, 2025
| .onConflict((oc) => oc.columns(['id']).doUpdateSet({isNotRemoved: true})) | ||
| .execute() | ||
|
|
||
| const res = await db |
Contributor
Author
There was a problem hiding this comment.
This takes around 20s on staging and affects 250 users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #9932
We query User.tms quite often to check permissions, so it's useful to be denormalized. To avoid update errors, I added triggers for Team and TeamMember operations which update the array.
There is also some inconsistent data in the database, I've added a migration to clean that up as well.
Demo
Nothing should change for the user.
Testing scenarios
Joining, leaving and archiving teams
Final checklist