@@ -130,7 +130,6 @@ select
130130from
131131 " assets"
132132 left join " exif" on " assets" ." id" = " exif" ." assetId"
133- left join " asset_stack" on " asset_stack" ." id" = " assets" ." stackId"
134133where
135134 " assets" ." id" = any ($1 ::uuid[])
136135
@@ -240,10 +239,7 @@ with
240239 " assets"
241240 where
242241 " assets" ." deletedAt" is null
243- and (
244- " assets" ." visibility" = $1
245- or " assets" ." visibility" = $2
246- )
242+ and " assets" ." visibility" in (' archive' , ' timeline' )
247243 )
248244select
249245 " timeBucket" ,
@@ -300,21 +296,14 @@ with
300296 where
301297 " stacked" ." stackId" = " assets" ." stackId"
302298 and " stacked" ." deletedAt" is null
303- and " stacked" ." visibility" ! = $1
299+ and " stacked" ." visibility" = $1
304300 group by
305301 " stacked" ." stackId"
306302 ) as " stacked_assets" on true
307303 where
308304 " assets" ." deletedAt" is null
309- and (
310- " assets" ." visibility" = $2
311- or " assets" ." visibility" = $3
312- )
313- and date_trunc(' MONTH' , " localDateTime" at time zone ' UTC' ) at time zone ' UTC' = $4
314- and (
315- " assets" ." visibility" = $5
316- or " assets" ." visibility" = $6
317- )
305+ and " assets" ." visibility" in (' archive' , ' timeline' )
306+ and date_trunc(' MONTH' , " localDateTime" at time zone ' UTC' ) at time zone ' UTC' = $2
318307 and not exists (
319308 select
320309 from
@@ -374,10 +363,10 @@ with
374363 " exif" ." assetId" = " assets" ." id"
375364 ) as " asset" on true
376365 where
377- " assets" ." ownerId" = $1 ::uuid
366+ " assets" ." visibility" in (' archive' , ' timeline' )
367+ and " assets" ." ownerId" = $1 ::uuid
378368 and " assets" ." duplicateId" is not null
379369 and " assets" ." deletedAt" is null
380- and " assets" ." visibility" != $2
381370 and " assets" ." stackId" is null
382371 group by
383372 " assets" ." duplicateId"
@@ -388,12 +377,12 @@ with
388377 from
389378 " duplicates"
390379 where
391- json_array_length(" assets" ) = $3
380+ json_array_length(" assets" ) = $2
392381 ),
393382 " removed_unique" as (
394383 update " assets"
395384 set
396- " duplicateId" = $4
385+ " duplicateId" = $3
397386 from
398387 " unique"
399388 where
0 commit comments