immich icon indicating copy to clipboard operation
immich copied to clipboard

Inconsistant number of items in album

Open chengguangnan opened this issue 10 months ago • 11 comments

The bug

I have a album which immich reported has 6478 items, but when I click the Select All button, after a processing delay, the web UI shows about 33k items selected.

By browser the timeline, it seems that all items are selected. So maybe there is is a counting error in considering how many items in an album?

I suspect that this is related to counting stacked Live Photo but I'm not sure. Moreover, by adding all the 33k selected items to a new albumn, immich will correctly report the new albumn has 33k items.

Screenshot:

Screenshot 2024-03-29 at 11 16 49 AM

The OS that Immich Server is running on

MacOS

Version of Immich Server

v1.100.0

Version of Immich Mobile App

n/a

Platform with the issue

  • [ ] Server
  • [X] Web
  • [ ] Mobile

Your docker-compose.yml content

n/a

Your .env content

n/a

Reproduction steps

1.
2.
3.
...

Additional information

No response

chengguangnan avatar Mar 29 '24 03:03 chengguangnan

Hey, could you check if that's still an issue? :)

danieldietzler avatar Apr 27 '24 21:04 danieldietzler

I upgraded to v1.102.3. Still see this in some albums.

Screenshot 2024-04-28 at 12 54 05 PM

chengguangnan avatar Apr 28 '24 04:04 chengguangnan

Ok @chengguangnan it would be awesome if you could test something for us: Following the guide in the docs, connect to the database. Then, run the following query:

SELECT COUNT(*) FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND NOT "b"."isVisible"

and share the result with us, please. Thanks! :)

danieldietzler avatar Apr 29 '24 19:04 danieldietzler

@danieldietzler

immich=# SELECT COUNT(*) FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND NOT "b"."isVisible"
immich-# ;
 count
-------
 28644
(1 row)

chengguangnan avatar May 04 '24 15:05 chengguangnan

Oh sorry I missed something. Can you try

SELECT COUNT(*) FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND "a"."albumsId" = '<album id>' AND NOT "b"."isVisible"

by replacing <album id> with the album id of the album that issue occurs in? (the album id should be part of the URL and look something like 0b0d5697-3347-4900-9d41-6679079fc218)

danieldietzler avatar May 04 '24 15:05 danieldietzler

Hey @danieldietzler , yes, those invisible assets adds up!

3215 selected + 198 invisible = 3413 items.

Screenshot 2024-05-05 at 11 00 45 AM

chengguangnan avatar May 05 '24 03:05 chengguangnan

Thanks! Can you remove the COUNT? My guess is that those are all the motion (video) part of motion assets, so I'd like to verify/disprove that.

SELECT * FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND "a"."albumsId" = '<album id>' AND NOT "b"."isVisible"

danieldietzler avatar May 05 '24 20:05 danieldietzler

Those are all videos. Here are some sample rows:

              albumsId               |               assetsId               |                  id                  |        deviceAssetId        |               ownerId                | deviceId | type  |                                           originalPath                                            |                                            previewPath                                             |       fileCreatedAt        |     fileModifiedAt     | isFavorite |   duration   |                                           thumbnailPath                                            | encodedVideoPath |                  checksum                  | isVisible | livePhotoVideoId |           updatedAt           |           createdAt           | isArchived |  originalFileName   |                                            sidecarPath                                            | isReadOnly |                  thumbhash                   | isOffline |              libraryId               | isExternal | deletedAt |       localDateTime        | stackId
175ce61a-6e96-43a4-8327-792897e3d987 | 01b92bca-901e-41a2-a0af-d3a525b85fe8 | 01b92bca-901e-41a2-a0af-d3a525b85fe8 | IMG_6464_083160.mov-2703967 | 56bfd748-c422-438e-9305-947a8825e78c | CLI      | VIDEO | upload/upload/56bfd748-c422-438e-9305-947a8825e78c/48/ee/48ee9fee-66b1-428c-a202-d21cfe6680bc.mov | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/01/b9/01b92bca-901e-41a2-a0af-d3a525b85fe8.jpeg | 2019-02-08 00:15:14+00     | 2024-01-17 10:10:17+00 | f          | 00:00:02.635 | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/01/b9/01b92bca-901e-41a2-a0af-d3a525b85fe8.webp |                  | \x09a1dcabe06e292979f02dc6b19b9355b91fcf1e | f         |                  | 2024-03-20 20:21:55.65237+00  | 2024-03-20 17:32:17.165474+00 | f          | IMG_6464_083160.mov |                                                                                                   | f          | \xe0f70d0d828988787f78777e877788758770780877 | f         | 14c86692-7fc3-4c1a-bd1e-1e1a87dc78dd | f          |           | 2019-02-07 14:15:14+00     
175ce61a-6e96-43a4-8327-792897e3d987 | 039851a0-21ae-4426-a3f6-3bda47a81995 | 039851a0-21ae-4426-a3f6-3bda47a81995 | IMG_4976_084393.mov-1837443 | 56bfd748-c422-438e-9305-947a8825e78c | CLI      | VIDEO | upload/upload/56bfd748-c422-438e-9305-947a8825e78c/a4/00/a40057e8-6bd1-409a-ab44-41978c78bd07.mov | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/03/98/039851a0-21ae-4426-a3f6-3bda47a81995.jpeg | 2019-02-01 02:31:10+00     | 2024-01-17 09:36:25+00 | f          | 00:00:02.018 | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/03/98/039851a0-21ae-4426-a3f6-3bda47a81995.webp |                  | \x1a0c1926ed1e21a17f0ee15433c7979b1ff80250 | f         |                  | 2024-03-20 19:48:54.553698+00 | 2024-03-20 17:09:05.137319+00 | f          | IMG_4976_084393.mov |                                                                                                   | f          | \x5cf8050d02bb60cd859949678ab45a68d09ae292f8 | f         | 14c86692-7fc3-4c1a-bd1e-1e1a87dc78dd | f          |           | 2019-01-31 16:31:10+00     |

chengguangnan avatar May 07 '24 14:05 chengguangnan

And they are not visible, ok. Thanks for input! I think we should be able to work with that now :)

danieldietzler avatar May 07 '24 14:05 danieldietzler

Maybe we should run a migration to remove these. What do you think @danieldietzler ?

jrasm91 avatar Sep 07 '24 12:09 jrasm91

I am always a bit scared to run migrations that delete stuff. But I think this should be fine, yea

danieldietzler avatar Sep 07 '24 12:09 danieldietzler