fix(teams): fix duplicate teams being shown when new public team visibility feature is enabled #2187
No reviewers
Labels
No Label
dependencies
duplicate
help wanted
invalid
kind/bug
kind/feature
needs reproduction
question
security
wontfix
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/vikunja#2187
Loading…
Reference in New Issue
No description provided.
Delete Branch "waza-ari/vikunja:fix-duplicate-teams-when-sharing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Sorry, missed another case that I only noticed after updating unstable in our environment... Due to the
INNER JOIN
on theteam_members
table and the newOR
conditions allowing teams with theisPublic
flag set totrue
, teams are returned multiple times. As we're only after the teams, a simple distinct query should fix the issue.Hi waza-ari!
Thank you for creating a PR!
I've deployed the frontend changes of this PR on a preview environment under this URL: https://2187-fix-duplicate-teams-when-sharing--vikunja-frontend-preview.netlify.app
You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/.
This preview does not contain any changes made to the api, only the frontend.
Have a nice day!
@ -309,3 +309,3 @@
builder.Eq{"team_members.user_id": a.GetID()},
),
)
).Distinct("teams.id")
Doesn't this either return only team ids or is not taken into account at all?
With native SQL I'd completely agree with you. Not entirely sure why, but I compared the SQL command executed before and after the change:
Before:
After:
Not entire sure why this is happening to be honest. Changing the code to
has the same effect:
My guess would be the
.Select()
overrides the.Distinct
.Can you move the
Distinct
to the main part of the query and combine it with theSelect
? Doesn't hurt to have it there always.I've been reading a bit and it looks like you're right. You don't even need
select
, you can callDistinct
directly on the engine which is automatically adding theSELECT
. Changed it accordingly.How can I reproduce the bug you're describing?
You'll need two users and two teams at the very least:
Teams:
Users:
User B then creates a new project and shares it. Team B will be returned twice
@konrad I don't think the CI failure is caused by the change - could you trigger the failed job again please?