-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix(server): searching for multiple people yields false positives #15447
Conversation
@@ -248,7 +248,7 @@ export function hasPeopleCte(db: Kysely<DB>, personIds: string[]) { | |||
.select('assetId') | |||
.where('personId', '=', anyUuid(personIds!)) | |||
.groupBy('assetId') | |||
.having((eb) => eb.fn.count('personId'), '>=', personIds.length), | |||
.having((eb) => eb.fn.count('personId').distinct(), '=', personIds.length), |
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.
Why equality here? I think it makes sense to include assets that also have other faces.
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 this would be better as a series of where exists
clauses instead.
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.
Assets with other faces are still included. However the other faces aren't counted in the first place because the where filters for only the people that were searched for so '>=' and '=' actually has the same effect. I think then '=' is the better choice because in my opinion '>=' suggests the possibility of the count being greater than personIds.length
and thus is confusing to the reader.
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.
Oh right, you're only counting the filtered set. That makes sense!
When searching for multiple people, only images with all of those people in them should show up. However, if an image has one person's face detected multiple times it would still show up because the query wasn't counting distinct personIds.