-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: add searching by tags #15395
base: main
Are you sure you want to change the base?
feat: add searching by tags #15395
Conversation
c62c943
to
8d65b47
Compare
e723d6f
to
648a9fd
Compare
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
async function getTagNames(tagIds: string[]) { | ||
const tagNames = await Promise.all( | ||
tagIds.map(async (tagId) => { | ||
const tag = await getTagById({ id: tagId }); | ||
if (tag.name == '') { | ||
return $t('no_name'); | ||
} | ||
return tag.name; | ||
}), | ||
); | ||
return tagNames.join(', '); | ||
} | ||
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.
I think we have a tag service/cache that can do this from a single request which loads all the tags once
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.
I looked through all uses of getTagById
and getAllTags
in the web code and couldn't find any place where it is being cached. Or do you mean an api endpoint to retrieve all tags at once? From what I can tell that doesn't exist.
We could use getAllTags
and then filter for the ones actually needed but I don't think that would be worth it as you would often search for only a single tag. The chip for people also retrieves each person individually.
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.
Ah, I think it was only used in the tags page.
Adds the feature to search for photos by one or multiple tags in the web, and support for it in the server.
This is my first time contributing to immich so apologies if some things aren't up to standard.
The tags section in the search modal
web/src/lib/components/shared-components/search-bar/search-tags-section.svelte
duplicates some code fromweb/src/lib/components/forms/tag-asset-form.svelte
. I couldn't use that component directly, as it is a full screen modal. Should I add a new component instead that is used by both?Also of note is that I slightly changed the behavior of the tags section to clear out the text whenever a tag is selected. This makes it much easier to select multiple tags using the keyboard. Maybe this should also be added to the full screen modal?
On the side of the server, having the tagIds functionality split up in searchAssetBuilder is a bit awkward. This is because as far as I can tell kysely requires CTEs to be added before calling selectFrom, but innerJoins to occur afterwards. I don't see a way to avoid this.(fixed now)Also I noticed a bug in the adjacent hasPeopleCte where it yields false positives. Should I open a separate PR for this?(I did)I would also like to add this functionality to the mobile app, however I haven't gotten around to it yet and I have no experience with flutter, so I'd prefer to do this in a separate PR at a later date if I can get it working.