-- NOTE: This file is auto generated by ./sql-generator -- SearchRepository.searchMetadata select "asset".* from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" where "asset"."visibility" = $1 and "asset"."fileCreatedAt" >= $2 and "asset_exif"."lensModel" = $3 and ( "asset"."ownerId" = $4 or exists ( select from "partner" where "partner"."sharedById" = "asset"."ownerId" and "partner"."sharedWithId" = $5 and ( $6 = any ("partner"."permissions") or "partner"."permissions" @> $7 ) and "partner"."inTimeline" = $8 ) or exists ( select from "album_asset" inner join "album_user" on "album_user"."albumId" = "album_asset"."albumId" and "album_user"."userId" = $9 where "album_asset"."assetId" = "asset"."id" and "album_user"."inTimeline" = $10 and "album_user"."albumId" in ( select "album_user"."albumId" from "album_user" where "album_user"."userId" = "asset"."ownerId" and ( $11 = any ("album_user"."permissions") or "album_user"."permissions" @> $12 ) ) ) ) and "asset"."isFavorite" = $13 and "asset"."deletedAt" is null order by "asset"."fileCreatedAt" desc limit $14 offset $15 -- SearchRepository.searchStatistics select count(*) as "total" from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" where "asset"."visibility" = $1 and "asset"."fileCreatedAt" >= $2 and "asset_exif"."lensModel" = $3 and ( "asset"."ownerId" = $4 or exists ( select from "partner" where "partner"."sharedById" = "asset"."ownerId" and "partner"."sharedWithId" = $5 and ( $6 = any ("partner"."permissions") or "partner"."permissions" @> $7 ) and "partner"."inTimeline" = $8 ) or exists ( select from "album_asset" inner join "album_user" on "album_user"."albumId" = "album_asset"."albumId" and "album_user"."userId" = $9 where "album_asset"."assetId" = "asset"."id" and "album_user"."inTimeline" = $10 and "album_user"."albumId" in ( select "album_user"."albumId" from "album_user" where "album_user"."userId" = "asset"."ownerId" and ( $11 = any ("album_user"."permissions") or "album_user"."permissions" @> $12 ) ) ) ) and "asset"."isFavorite" = $13 and "asset"."deletedAt" is null -- SearchRepository.searchRandom select "asset".* from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" where "asset"."visibility" = $1 and "asset"."fileCreatedAt" >= $2 and "asset_exif"."lensModel" = $3 and ( "asset"."ownerId" = $4 or exists ( select from "partner" where "partner"."sharedById" = "asset"."ownerId" and "partner"."sharedWithId" = $5 and ( $6 = any ("partner"."permissions") or "partner"."permissions" @> $7 ) and "partner"."inTimeline" = $8 ) or exists ( select from "album_asset" inner join "album_user" on "album_user"."albumId" = "album_asset"."albumId" and "album_user"."userId" = $9 where "album_asset"."assetId" = "asset"."id" and "album_user"."inTimeline" = $10 and "album_user"."albumId" in ( select "album_user"."albumId" from "album_user" where "album_user"."userId" = "asset"."ownerId" and ( $11 = any ("album_user"."permissions") or "album_user"."permissions" @> $12 ) ) ) ) and "asset"."isFavorite" = $13 and "asset"."deletedAt" is null order by random() limit $14 -- SearchRepository.searchLargeAssets select "asset".*, to_json("asset_exif") as "exifInfo" from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" where "asset"."visibility" = $1 and "asset"."fileCreatedAt" >= $2 and "asset_exif"."lensModel" = $3 and ( "asset"."ownerId" = $4 or exists ( select from "partner" where "partner"."sharedById" = "asset"."ownerId" and "partner"."sharedWithId" = $5 and ( $6 = any ("partner"."permissions") or "partner"."permissions" @> $7 ) and "partner"."inTimeline" = $8 ) or exists ( select from "album_asset" inner join "album_user" on "album_user"."albumId" = "album_asset"."albumId" and "album_user"."userId" = $9 where "album_asset"."assetId" = "asset"."id" and "album_user"."inTimeline" = $10 and "album_user"."albumId" in ( select "album_user"."albumId" from "album_user" where "album_user"."userId" = "asset"."ownerId" and ( $11 = any ("album_user"."permissions") or "album_user"."permissions" @> $12 ) ) ) ) and "asset"."isFavorite" = $13 and "asset"."deletedAt" is null and "asset_exif"."fileSizeInByte" > $14 order by "asset_exif"."fileSizeInByte" desc limit $15 -- SearchRepository.searchSmart begin set local vchordrq.probes = 1 select "asset".* from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" inner join "smart_search" on "asset"."id" = "smart_search"."assetId" where "asset"."visibility" = $1 and "asset"."fileCreatedAt" >= $2 and "asset_exif"."lensModel" = $3 and ( "asset"."ownerId" = $4 or exists ( select from "partner" where "partner"."sharedById" = "asset"."ownerId" and "partner"."sharedWithId" = $5 and ( $6 = any ("partner"."permissions") or "partner"."permissions" @> $7 ) and "partner"."inTimeline" = $8 ) or exists ( select from "album_asset" inner join "album_user" on "album_user"."albumId" = "album_asset"."albumId" and "album_user"."userId" = $9 where "album_asset"."assetId" = "asset"."id" and "album_user"."inTimeline" = $10 and "album_user"."albumId" in ( select "album_user"."albumId" from "album_user" where "album_user"."userId" = "asset"."ownerId" and ( $11 = any ("album_user"."permissions") or "album_user"."permissions" @> $12 ) ) ) ) and "asset"."isFavorite" = $13 and "asset"."deletedAt" is null order by smart_search.embedding <=> $14 limit $15 offset $16 commit -- SearchRepository.getEmbedding select * from "smart_search" where "assetId" = $1 -- SearchRepository.searchFaces begin set local vchordrq.probes = 1 with "cte" as ( select "asset_face"."id", "asset_face"."faceClusterId", face_search.embedding <=> $1 as "distance", "asset"."ownerId" from "asset_face" inner join "asset" on "asset"."id" = "asset_face"."assetId" inner join "face_search" on "face_search"."faceId" = "asset_face"."id" left join "person" on "person"."faceClusterId" = "asset_face"."faceClusterId" where "asset"."ownerId" in ( select "user"."id" from "user" where "user"."trustedGroupId" in ( select "user"."trustedGroupId" from "user" where "user"."id" = any ($2::uuid[]) ) ) and "asset"."deletedAt" is null order by "distance" limit $3 ) select * from "cte" where "cte"."distance" <= $4 commit -- SearchRepository.searchPlaces select * from "geodata_places" where f_unaccent (name) %>> f_unaccent ($1) or f_unaccent ("admin2Name") %>> f_unaccent ($2) or f_unaccent ("admin1Name") %>> f_unaccent ($3) or f_unaccent ("alternateNames") %>> f_unaccent ($4) order by coalesce(f_unaccent (name) <->>> f_unaccent ($5), 0.1) + coalesce( f_unaccent ("admin2Name") <->>> f_unaccent ($6), 0.1 ) + coalesce( f_unaccent ("admin1Name") <->>> f_unaccent ($7), 0.1 ) + coalesce( f_unaccent ("alternateNames") <->>> f_unaccent ($8), 0.1 ) limit $9 -- SearchRepository.getAssetsByCity with recursive "cte" as ( ( select "city", "assetId" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "asset"."ownerId" = any ($1::uuid[]) and "asset"."visibility" = $2 and "asset"."type" = $3 and "asset"."deletedAt" is null order by "city" limit $4 ) union all ( select "l"."city", "l"."assetId" from "cte" inner join lateral ( select "city", "assetId" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "asset"."ownerId" = any ($5::uuid[]) and "asset"."visibility" = $6 and "asset"."type" = $7 and "asset"."deletedAt" is null and "asset_exif"."city" > "cte"."city" order by "city" limit $8 ) as "l" on true ) ) select "asset".*, to_jsonb("asset_exif") as "exifInfo" from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" inner join "cte" on "asset"."id" = "cte"."assetId" order by "asset_exif"."city" -- SearchRepository.getStates select distinct on ("state") "state" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "ownerId" = any ($1::uuid[]) and "visibility" = $2 and "deletedAt" is null and "state" is not null and "state" != $3 -- SearchRepository.getCities select distinct on ("city") "city" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "ownerId" = any ($1::uuid[]) and "visibility" = $2 and "deletedAt" is null and "city" is not null and "city" != $3 -- SearchRepository.getCameraMakes select distinct on ("make") "make" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "ownerId" = any ($1::uuid[]) and "visibility" = $2 and "deletedAt" is null and "make" is not null and "make" != $3 -- SearchRepository.getCameraModels select distinct on ("model") "model" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "ownerId" = any ($1::uuid[]) and "visibility" = $2 and "deletedAt" is null and "model" is not null and "model" != $3 -- SearchRepository.getCameraLensModels select distinct on ("lensModel") "lensModel" from "asset_exif" inner join "asset" on "asset"."id" = "asset_exif"."assetId" where "ownerId" = any ($1::uuid[]) and "visibility" = $2 and "deletedAt" is null and "lensModel" is not null and "lensModel" != $3