mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
feat(server): sort images in duplicate groups by date (#18347)
This restores behaviour introduced in 562fec6e2bc293ff977730ce809a7ee182eb3eef and lost in 2e12c46980b45072beb0f4ba125f821053b13851.
This commit is contained in:
parent
c8641d24f6
commit
00a77c2d6a
@ -296,7 +296,11 @@ with
|
||||
"duplicates" as (
|
||||
select
|
||||
"assets"."duplicateId",
|
||||
jsonb_agg("asset") as "assets"
|
||||
json_agg(
|
||||
"asset"
|
||||
order by
|
||||
"assets"."localDateTime" asc
|
||||
) as "assets"
|
||||
from
|
||||
"assets"
|
||||
left join lateral (
|
||||
@ -323,7 +327,7 @@ with
|
||||
from
|
||||
"duplicates"
|
||||
where
|
||||
jsonb_array_length("assets") = $3
|
||||
json_array_length("assets") = $3
|
||||
),
|
||||
"removed_unique" as (
|
||||
update "assets"
|
||||
|
@ -649,10 +649,7 @@ export class AssetRepository {
|
||||
)
|
||||
.select('assets.duplicateId')
|
||||
.select((eb) =>
|
||||
eb
|
||||
.fn('jsonb_agg', [eb.table('asset')])
|
||||
.$castTo<MapAsset[]>()
|
||||
.as('assets'),
|
||||
eb.fn.jsonAgg('asset').orderBy('assets.localDateTime', 'asc').$castTo<MapAsset[]>().as('assets'),
|
||||
)
|
||||
.where('assets.ownerId', '=', asUuid(userId))
|
||||
.where('assets.duplicateId', 'is not', null)
|
||||
@ -666,7 +663,7 @@ export class AssetRepository {
|
||||
qb
|
||||
.selectFrom('duplicates')
|
||||
.select('duplicateId')
|
||||
.where((eb) => eb(eb.fn('jsonb_array_length', ['assets']), '=', 1)),
|
||||
.where((eb) => eb(eb.fn('json_array_length', ['assets']), '=', 1)),
|
||||
)
|
||||
.with('removed_unique', (qb) =>
|
||||
qb
|
||||
@ -677,7 +674,7 @@ export class AssetRepository {
|
||||
)
|
||||
.selectFrom('duplicates')
|
||||
.selectAll()
|
||||
// TODO: compare with filtering by jsonb_array_length > 1
|
||||
// TODO: compare with filtering by json_array_length > 1
|
||||
.where(({ not, exists }) =>
|
||||
not(exists((eb) => eb.selectFrom('unique').whereRef('unique.duplicateId', '=', 'duplicates.duplicateId'))),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user