Skip to content
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

Map View: Shows assets multiple times if they are in multiple albums #16129

Closed
1 of 3 tasks
jbcodemonkey opened this issue Feb 15, 2025 · 1 comment · Fixed by #16245
Closed
1 of 3 tasks

Map View: Shows assets multiple times if they are in multiple albums #16129

jbcodemonkey opened this issue Feb 15, 2025 · 1 comment · Fixed by #16245

Comments

@jbcodemonkey
Copy link

jbcodemonkey commented Feb 15, 2025

The bug

In Map view, the number of assets is a total of the number of albums the asset(s) appear(s) in.
For example, I have a single picture in four albums. On the Map, it shows as a number 4, and when I click it, the 'next' arrow will click forward as though there are four items, but it's the same image.

If I have one image in two albums and another image in four albums at the same location, the Map displays a 6, and when I click it, I will see the first image, but I must click 'next' twice to see the second image. The behavior seems to treat each album membership as a separate image, even though it is the same single image. If the first item is in four albums, I must click 'next' four times to get the next actual asset.

This behavior is consistent: however many albums an asset appears in is used as the count on the map and affects cycling through the items when viewing them.

The sample autogenerated query server/src/queries/map.repository.sql returns multiple rows per asset, one row for each album the asset is in.

This query works to return one row per unique asset when run against the database directly:

select distinct on ("assets"."id")
  "id",
  "exif"."latitude" as "lat",
  "exif"."longitude" as "lon",
  "exif"."city",
  "exif"."state",
  "exif"."country"
from
  "assets"
  inner join "exif" on "assets"."id" = "exif"."assetId"
  and "exif"."latitude" is not null
  and "exif"."longitude" is not null
  left join "albums_assets_assets" on "assets"."id" = "albums_assets_assets"."assetsId"
where
  "deletedAt" is null
order by
  "assets"."id", "fileCreatedAt" desc

I think changes need to be made to https://github.com/immich-app/immich/blob/main/server/src/repositories/map.repository.ts to generate a query that returns only one row per asset.

The OS that Immich Server is running on

Synology Docker

Version of Immich Server

v1.126.1

Version of Immich Mobile App

NA

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

NA

Your .env content

NA

Reproduction steps

  1. View the map with assets that exist in more than one album
  2. Observe the count is a total of how many times the asset(s) appear in albums

Relevant log output

Additional information

No response

@jbcodemonkey
Copy link
Author

jbcodemonkey commented Feb 16, 2025

I did a bit of research and a bit of testing. This does a 'select distinct' query and returns one row per unique asset.

Created PR: #16131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant