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 (
|
"duplicates" as (
|
||||||
select
|
select
|
||||||
"assets"."duplicateId",
|
"assets"."duplicateId",
|
||||||
jsonb_agg("asset") as "assets"
|
json_agg(
|
||||||
|
"asset"
|
||||||
|
order by
|
||||||
|
"assets"."localDateTime" asc
|
||||||
|
) as "assets"
|
||||||
from
|
from
|
||||||
"assets"
|
"assets"
|
||||||
left join lateral (
|
left join lateral (
|
||||||
@ -323,7 +327,7 @@ with
|
|||||||
from
|
from
|
||||||
"duplicates"
|
"duplicates"
|
||||||
where
|
where
|
||||||
jsonb_array_length("assets") = $3
|
json_array_length("assets") = $3
|
||||||
),
|
),
|
||||||
"removed_unique" as (
|
"removed_unique" as (
|
||||||
update "assets"
|
update "assets"
|
||||||
|
@ -649,10 +649,7 @@ export class AssetRepository {
|
|||||||
)
|
)
|
||||||
.select('assets.duplicateId')
|
.select('assets.duplicateId')
|
||||||
.select((eb) =>
|
.select((eb) =>
|
||||||
eb
|
eb.fn.jsonAgg('asset').orderBy('assets.localDateTime', 'asc').$castTo<MapAsset[]>().as('assets'),
|
||||||
.fn('jsonb_agg', [eb.table('asset')])
|
|
||||||
.$castTo<MapAsset[]>()
|
|
||||||
.as('assets'),
|
|
||||||
)
|
)
|
||||||
.where('assets.ownerId', '=', asUuid(userId))
|
.where('assets.ownerId', '=', asUuid(userId))
|
||||||
.where('assets.duplicateId', 'is not', null)
|
.where('assets.duplicateId', 'is not', null)
|
||||||
@ -666,7 +663,7 @@ export class AssetRepository {
|
|||||||
qb
|
qb
|
||||||
.selectFrom('duplicates')
|
.selectFrom('duplicates')
|
||||||
.select('duplicateId')
|
.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) =>
|
.with('removed_unique', (qb) =>
|
||||||
qb
|
qb
|
||||||
@ -677,7 +674,7 @@ export class AssetRepository {
|
|||||||
)
|
)
|
||||||
.selectFrom('duplicates')
|
.selectFrom('duplicates')
|
||||||
.selectAll()
|
.selectAll()
|
||||||
// TODO: compare with filtering by jsonb_array_length > 1
|
// TODO: compare with filtering by json_array_length > 1
|
||||||
.where(({ not, exists }) =>
|
.where(({ not, exists }) =>
|
||||||
not(exists((eb) => eb.selectFrom('unique').whereRef('unique.duplicateId', '=', 'duplicates.duplicateId'))),
|
not(exists((eb) => eb.selectFrom('unique').whereRef('unique.duplicateId', '=', 'duplicates.duplicateId'))),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user