Skip to content

[FEAT] Introduced RequireAllPeople flag to filter assets for people in an AND fashion#626

Open
FlorianObermayer wants to merge 1 commit intoimmichFrame:mainfrom
FlorianObermayer:Feat/Add-RequireAllPeople-setting-for-AND-based-person-filtering
Open

[FEAT] Introduced RequireAllPeople flag to filter assets for people in an AND fashion#626
FlorianObermayer wants to merge 1 commit intoimmichFrame:mainfrom
FlorianObermayer:Feat/Add-RequireAllPeople-setting-for-AND-based-person-filtering

Conversation

@FlorianObermayer
Copy link
Copy Markdown

@FlorianObermayer FlorianObermayer commented Apr 11, 2026

This pull request introduces a new RequireAllPeople setting that changes how ImmichFrame filters assets by person.

Before: Assets are returned if they feature any of the configured people (OR logic).
After: When RequireAllPeople: true is set, only assets featuring all configured people are returned (AND logic).

This is useful for finding shared moments — for example, only showing photos where both Person A and Person B appear together.

Usage:

People:
  - <person-id-1>
  - <person-id-2>
RequireAllPeople: true

Summary by CodeRabbit

  • New Features

    • Added per-account RequireAllPeople option: when enabled, images must contain all listed people to be shown (default: off).
  • Documentation

    • Configuration docs updated to describe the new RequireAllPeople setting.
  • Tests

    • Added tests covering RequireAllPeople behavior, including pagination and aggregation scenarios.
  • Chores

    • Sample config and example env files updated to include the new setting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 80cd0d0a-e16d-44c5-a703-fd9c40bb2d6a

📥 Commits

Reviewing files that changed from the base of the PR and between 7c6dfa2 and d5821fd.

📒 Files selected for processing (13)
  • ImmichFrame.Core.Tests/Logic/Pool/PersonAssetsPoolTests.cs
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi.Tests/Resources/TestV2_NoGeneral.json
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • docker/Settings.example.json
  • docker/Settings.example.yml
  • docker/example.env
  • docs/docs/getting-started/configuration.md
✅ Files skipped from review due to trivial changes (6)
  • docker/example.env
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2_NoGeneral.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs
🚧 Files skipped from review as they are similar to previous changes (7)
  • docker/Settings.example.json
  • docs/docs/getting-started/configuration.md
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • docker/Settings.example.yml
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.Core.Tests/Logic/Pool/PersonAssetsPoolTests.cs

📝 Walkthrough

Walkthrough

Added a per-account RequireAllPeople boolean and updated PeopleAssetsPool to either search once for assets containing all configured people or perform per-person searches; tests, configs, docs, and examples updated accordingly.

Changes

Cohort / File(s) Summary
Core Interface & Pool Logic
ImmichFrame.Core/Interfaces/IServerSettings.cs, ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs
Added IAccountSettings.RequireAllPeople and changed PeopleAssetsPool.LoadAssets() to build PersonIds as a single-group query when enabled; otherwise performs per-person searches with existing pagination.
Web API Models & Adapters
ImmichFrame.WebApi/Models/ServerSettings.cs, ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
Added RequireAllPeople property to ServerAccountSettings and V1 settings; adapter forwards the value to IAccountSettings.
Tests & Test Resources
ImmichFrame.Core.Tests/Logic/Pool/PersonAssetsPoolTests.cs, ImmichFrame.WebApi.Tests/Resources/TestV1.json, .../TestV2.json, .../TestV2.yml, .../TestV2_NoGeneral.json
Added three NUnit tests covering RequireAllPeople=true scenarios (combined single search, paginated combined search, empty-result handling). Updated test resource files to include the new flag.
Documentation & Examples
docs/docs/getting-started/configuration.md, docker/Settings.example.json, docker/Settings.example.yml, docker/example.env
Documented Accounts[].RequireAllPeople and added the flag to example Docker/YAML/env files and docs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested reviewers

  • 3rob3
  • JW-CH

Poem

🐇 I nibbled through configs, neat and spry,
Gathered people IDs under one sky.
One hop for all faces, pages fold in tune,
Tests clap their paws beneath the moon.
Hooray — a feature that makes searches bloom!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main feature introduced: a RequireAllPeople flag that changes asset filtering logic from OR to AND for people-based filtering.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FlorianObermayer FlorianObermayer marked this pull request as ready for review April 11, 2026 09:28
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs (1)

12-23: ⚠️ Potential issue | 🟠 Major

Guard against empty People in AND mode to avoid unintended search calls.

At Line 21, RequireAllPeople=true with an empty people list creates a single empty group and still executes SearchAssetsAsync. Add an early Count == 0 return to keep filtering behavior safe and predictable.

💡 Proposed fix
         var people = accountSettings.People;
-        if (people == null)
+        if (people == null || people.Count == 0)
         {
             return personAssets;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs` around lines 12 - 23, The
code builds personIdGroups from accountSettings.People and in AND mode
(accountSettings.RequireAllPeople) it can create a single empty group causing
SearchAssetsAsync to run; add an early guard after the null check that if
accountSettings.RequireAllPeople is true and accountSettings.People.Count == 0
then return personAssets immediately to avoid performing searches for an empty
people list; update the logic around personIdGroups, RequireAllPeople, and the
call sites that use personIdGroups/SearchAssetsAsync so the empty-case is
short-circuited.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs`:
- Around line 12-23: The code builds personIdGroups from accountSettings.People
and in AND mode (accountSettings.RequireAllPeople) it can create a single empty
group causing SearchAssetsAsync to run; add an early guard after the null check
that if accountSettings.RequireAllPeople is true and
accountSettings.People.Count == 0 then return personAssets immediately to avoid
performing searches for an empty people list; update the logic around
personIdGroups, RequireAllPeople, and the call sites that use
personIdGroups/SearchAssetsAsync so the empty-case is short-circuited.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e668ca15-c79d-4a15-8e79-6f1c171e5712

📥 Commits

Reviewing files that changed from the base of the PR and between 265a890 and 2ba1121.

📒 Files selected for processing (10)
  • ImmichFrame.Core.Tests/Logic/Pool/PersonAssetsPoolTests.cs
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi.Tests/Resources/TestV2_NoGeneral.json
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • docs/docs/getting-started/configuration.md

@3rob3 3rob3 added the enhancement New feature or request label Apr 11, 2026
@3rob3
Copy link
Copy Markdown
Collaborator

3rob3 commented Apr 11, 2026

Nice! This LGTM. Can you also add the new setting to the examples please (they are in the docker folder).
example.env
settings.example.json
settings.example.yml

@FlorianObermayer FlorianObermayer force-pushed the Feat/Add-RequireAllPeople-setting-for-AND-based-person-filtering branch from 2ba1121 to 7c6dfa2 Compare April 11, 2026 23:12
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs (1)

48-52: ⚠️ Potential issue | 🟠 Major

Pagination condition uses the wrong signal and can drop pages.

Line 52 compares total to batchSize; this usually reflects global match count, not items returned in the current page. For totals > 1000, pagination can stop early after page 1.

Proposed fix
-            int total;
+            int itemsInPage;
             do
             {
                 var metadataBody = new MetadataSearchDto
                 {
                     Page = page,
                     Size = batchSize,
                     PersonIds = personIds,
                     WithExif = true,
                     WithPeople = true
                 };

                 if (!accountSettings.ShowVideos)
                 {
                     metadataBody.Type = AssetTypeEnum.IMAGE;
                 }

                 var personInfo = await immichApi.SearchAssetsAsync(metadataBody, ct);

-                total = personInfo.Assets.Total;
+                itemsInPage = personInfo.Assets.Items.Count;

                 personAssets.AddRange(personInfo.Assets.Items);
                 page++;
-            } while (total == batchSize);
+            } while (itemsInPage == batchSize);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs` around lines 48 - 52, The
pagination loop in PeopleAssetsPool (in PeopleAssetsPool.cs) uses the wrong
condition—comparing total to batchSize—so pagination can stop early; change the
loop to continue while the current page returned a full batch (e.g., while
(personInfo.Assets.Items.Count == batchSize) or equivalent) and rely on the
returned item count (personInfo.Assets.Items) instead of total; ensure
personAssets.AddRange(personInfo.Assets.Items) and page++ remain unchanged and
that total is used only for metadata, not the loop condition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docker/Settings.example.yml`:
- Line 1: The file containing the "General:" YAML header has CRLF endings;
convert that file to LF line endings (e.g., run dos2unix on the file or set your
editor to save with LF, or run git add --renormalize <file>) and recommit so the
"General:" line (and whole file) uses '\n' endings to satisfy YAMLlint/CI
checks. Ensure your local git core.autocrlf or editor settings are updated to
prevent reintroducing CRLF.

In `@ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs`:
- Around line 21-23: If accountSettings.RequireAllPeople is true but the people
collection is empty, the current logic builds a single empty group in
personIdGroups and still performs the search; guard this by checking
people.Any() (or people.Count > 0) before creating personIdGroups and before
executing the search in the PeopleAssetsPool logic: when RequireAllPeople is
true and people is empty, short-circuit to return an empty result (or skip the
search) instead of constructing an empty group; update the code paths that
reference personIdGroups and the search invocation so they only run when people
has elements.

---

Outside diff comments:
In `@ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs`:
- Around line 48-52: The pagination loop in PeopleAssetsPool (in
PeopleAssetsPool.cs) uses the wrong condition—comparing total to batchSize—so
pagination can stop early; change the loop to continue while the current page
returned a full batch (e.g., while (personInfo.Assets.Items.Count == batchSize)
or equivalent) and rely on the returned item count (personInfo.Assets.Items)
instead of total; ensure personAssets.AddRange(personInfo.Assets.Items) and
page++ remain unchanged and that total is used only for metadata, not the loop
condition.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 43019efb-3523-44c6-ad49-f8c07e10d8e1

📥 Commits

Reviewing files that changed from the base of the PR and between 2ba1121 and 7c6dfa2.

📒 Files selected for processing (13)
  • ImmichFrame.Core.Tests/Logic/Pool/PersonAssetsPoolTests.cs
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi.Tests/Resources/TestV2_NoGeneral.json
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • docker/Settings.example.json
  • docker/Settings.example.yml
  • docker/example.env
  • docs/docs/getting-started/configuration.md
✅ Files skipped from review due to trivial changes (3)
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.Core.Tests/Logic/Pool/PersonAssetsPoolTests.cs
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/docs/getting-started/configuration.md
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV2_NoGeneral.json
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json

Comment thread docker/Settings.example.yml Outdated
Comment thread ImmichFrame.Core/Logic/Pool/PeopleAssetsPool.cs
@FlorianObermayer FlorianObermayer marked this pull request as draft April 11, 2026 23:18
@FlorianObermayer
Copy link
Copy Markdown
Author

Nice! This LGTM. Can you also add the new setting to the examples please (they are in the docker folder). example.env settings.example.json settings.example.yml

Just amended the change but apparently I have broken line ending settings. Moved the PR into draft state until those are resolved.

@FlorianObermayer FlorianObermayer force-pushed the Feat/Add-RequireAllPeople-setting-for-AND-based-person-filtering branch from 7c6dfa2 to d5821fd Compare April 11, 2026 23:26
@FlorianObermayer FlorianObermayer marked this pull request as ready for review April 11, 2026 23:26
@FlorianObermayer
Copy link
Copy Markdown
Author

Nice! This LGTM. Can you also add the new setting to the examples please (they are in the docker folder). example.env settings.example.json settings.example.yml

Just amended the change but apparently I have broken line ending settings. Moved the PR into draft state until those are resolved.

Done! I think there are some line ending differences in this project, though (most cs files are CLRF, while the example files are LF. Maybe worth to pull straight at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants