2024-02-12 20:50:47 -05:00
|
|
|
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
|
|
|
|
|
|
-- SearchRepository.searchMetadata
|
2025-01-09 11:15:41 -05:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset".*
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
|
|
|
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."visibility" = $1
|
|
|
|
|
and "asset"."fileCreatedAt" >= $2
|
|
|
|
|
and "asset_exif"."lensModel" = $3
|
|
|
|
|
and "asset"."ownerId" = any ($4::uuid[])
|
|
|
|
|
and "asset"."isFavorite" = $5
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."fileCreatedAt" desc
|
2025-01-09 11:15:41 -05:00
|
|
|
limit
|
|
|
|
|
$6
|
|
|
|
|
offset
|
|
|
|
|
$7
|
2024-02-12 20:50:47 -05:00
|
|
|
|
2025-06-07 11:12:53 +10:00
|
|
|
-- SearchRepository.searchStatistics
|
|
|
|
|
select
|
|
|
|
|
count(*) as "total"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
|
|
|
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
2025-06-07 11:12:53 +10:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."visibility" = $1
|
|
|
|
|
and "asset"."fileCreatedAt" >= $2
|
|
|
|
|
and "asset_exif"."lensModel" = $3
|
|
|
|
|
and "asset"."ownerId" = any ($4::uuid[])
|
|
|
|
|
and "asset"."isFavorite" = $5
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-06-07 11:12:53 +10:00
|
|
|
|
2024-09-30 00:29:35 -04:00
|
|
|
-- SearchRepository.searchRandom
|
2025-01-09 11:15:41 -05:00
|
|
|
(
|
|
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset".*
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
|
|
|
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."visibility" = $1
|
|
|
|
|
and "asset"."fileCreatedAt" >= $2
|
|
|
|
|
and "asset_exif"."lensModel" = $3
|
|
|
|
|
and "asset"."ownerId" = any ($4::uuid[])
|
|
|
|
|
and "asset"."isFavorite" = $5
|
|
|
|
|
and "asset"."deletedAt" is null
|
|
|
|
|
and "asset"."id" < $6
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
2025-01-26 08:06:18 -06:00
|
|
|
random()
|
2025-01-09 11:15:41 -05:00
|
|
|
limit
|
|
|
|
|
$7
|
|
|
|
|
)
|
|
|
|
|
union all
|
|
|
|
|
(
|
|
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset".*
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
|
|
|
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."visibility" = $8
|
|
|
|
|
and "asset"."fileCreatedAt" >= $9
|
|
|
|
|
and "asset_exif"."lensModel" = $10
|
|
|
|
|
and "asset"."ownerId" = any ($11::uuid[])
|
|
|
|
|
and "asset"."isFavorite" = $12
|
|
|
|
|
and "asset"."deletedAt" is null
|
|
|
|
|
and "asset"."id" > $13
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
2025-01-26 08:06:18 -06:00
|
|
|
random()
|
2025-01-09 11:15:41 -05:00
|
|
|
limit
|
|
|
|
|
$14
|
|
|
|
|
)
|
2025-01-24 00:41:54 -05:00
|
|
|
limit
|
|
|
|
|
$15
|
2024-09-30 00:29:35 -04:00
|
|
|
|
2024-02-12 20:50:47 -05:00
|
|
|
-- SearchRepository.searchSmart
|
2025-05-20 09:36:43 -04:00
|
|
|
begin
|
|
|
|
|
set
|
|
|
|
|
local vchordrq.probes = 1
|
2025-01-09 11:15:41 -05:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset".*
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
|
|
|
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
|
|
|
|
inner join "smart_search" on "asset"."id" = "smart_search"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."visibility" = $1
|
|
|
|
|
and "asset"."fileCreatedAt" >= $2
|
|
|
|
|
and "asset_exif"."lensModel" = $3
|
|
|
|
|
and "asset"."ownerId" = any ($4::uuid[])
|
|
|
|
|
and "asset"."isFavorite" = $5
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
2025-01-22 22:15:38 +00:00
|
|
|
smart_search.embedding <=> $6
|
2025-01-09 11:15:41 -05:00
|
|
|
limit
|
|
|
|
|
$7
|
|
|
|
|
offset
|
|
|
|
|
$8
|
2025-05-20 09:36:43 -04:00
|
|
|
commit
|
2024-02-12 20:50:47 -05:00
|
|
|
|
|
|
|
|
-- SearchRepository.searchFaces
|
2025-05-20 09:36:43 -04:00
|
|
|
begin
|
|
|
|
|
set
|
|
|
|
|
local vchordrq.probes = 1
|
2025-01-09 11:15:41 -05:00
|
|
|
with
|
|
|
|
|
"cte" as (
|
|
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."id",
|
|
|
|
|
"asset_face"."personId",
|
2025-01-22 22:15:38 +00:00
|
|
|
face_search.embedding <=> $1 as "distance"
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"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"."id" = "asset_face"."personId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."ownerId" = any ($2::uuid[])
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
2025-05-20 09:36:43 -04:00
|
|
|
"distance"
|
2025-01-09 11:15:41 -05:00
|
|
|
limit
|
2025-05-20 09:36:43 -04:00
|
|
|
$3
|
2024-02-12 20:50:47 -05:00
|
|
|
)
|
2025-01-09 11:15:41 -05:00
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"cte"
|
|
|
|
|
where
|
2025-05-20 09:36:43 -04:00
|
|
|
"cte"."distance" <= $4
|
|
|
|
|
commit
|
2024-02-24 01:42:37 +01:00
|
|
|
|
|
|
|
|
-- SearchRepository.searchPlaces
|
2025-01-09 11:15:41 -05:00
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"geodata_places"
|
|
|
|
|
where
|
2024-02-24 01:42:37 +01:00
|
|
|
f_unaccent (name) %>> f_unaccent ($1)
|
2025-01-09 11:15:41 -05:00
|
|
|
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),
|
2024-03-31 10:59:11 -04:00
|
|
|
0.1
|
2025-01-09 11:15:41 -05:00
|
|
|
) + coalesce(
|
|
|
|
|
f_unaccent ("admin1Name") <->>> f_unaccent ($7),
|
2024-03-31 10:59:11 -04:00
|
|
|
0.1
|
2025-01-09 11:15:41 -05:00
|
|
|
) + coalesce(
|
|
|
|
|
f_unaccent ("alternateNames") <->>> f_unaccent ($8),
|
2024-03-31 10:59:11 -04:00
|
|
|
0.1
|
2025-01-09 11:15:41 -05:00
|
|
|
)
|
|
|
|
|
limit
|
|
|
|
|
$9
|
2024-03-19 23:23:57 -04:00
|
|
|
|
|
|
|
|
-- SearchRepository.getAssetsByCity
|
2025-01-09 11:15:41 -05:00
|
|
|
with recursive
|
|
|
|
|
"cte" as (
|
2024-03-19 23:23:57 -04:00
|
|
|
(
|
2025-01-09 11:15:41 -05:00
|
|
|
select
|
|
|
|
|
"city",
|
2024-03-19 23:23:57 -04:00
|
|
|
"assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."ownerId" = any ($1::uuid[])
|
|
|
|
|
and "asset"."visibility" = $2
|
|
|
|
|
and "asset"."type" = $3
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
|
|
|
|
"city"
|
|
|
|
|
limit
|
2025-05-06 12:12:48 -05:00
|
|
|
$4
|
2025-01-09 11:15:41 -05:00
|
|
|
)
|
|
|
|
|
union all
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"l"."city",
|
|
|
|
|
"l"."assetId"
|
|
|
|
|
from
|
|
|
|
|
"cte"
|
|
|
|
|
inner join lateral (
|
|
|
|
|
select
|
|
|
|
|
"city",
|
|
|
|
|
"assetId"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."ownerId" = any ($5::uuid[])
|
|
|
|
|
and "asset"."visibility" = $6
|
|
|
|
|
and "asset"."type" = $7
|
|
|
|
|
and "asset"."deletedAt" is null
|
|
|
|
|
and "asset_exif"."city" > "cte"."city"
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
|
|
|
|
"city"
|
|
|
|
|
limit
|
2025-05-06 12:12:48 -05:00
|
|
|
$8
|
2025-01-09 11:15:41 -05:00
|
|
|
) as "l" on true
|
2024-03-19 23:23:57 -04:00
|
|
|
)
|
|
|
|
|
)
|
2025-01-09 11:15:41 -05:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset".*,
|
|
|
|
|
to_jsonb("asset_exif") as "exifInfo"
|
2025-01-09 11:15:41 -05:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
|
|
|
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
|
|
|
|
inner join "cte" on "asset"."id" = "cte"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
order by
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"."city"
|
2024-09-18 08:44:22 -04:00
|
|
|
|
|
|
|
|
-- SearchRepository.getStates
|
2025-01-09 11:15:41 -05:00
|
|
|
select distinct
|
|
|
|
|
on ("state") "state"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-01-22 22:15:38 +00:00
|
|
|
"ownerId" = any ($1::uuid[])
|
2025-06-02 10:33:08 -04:00
|
|
|
and "visibility" = $2
|
2025-01-09 11:15:41 -05:00
|
|
|
and "deletedAt" is null
|
|
|
|
|
and "state" is not null
|
2024-09-18 08:44:22 -04:00
|
|
|
|
|
|
|
|
-- SearchRepository.getCities
|
2025-01-09 11:15:41 -05:00
|
|
|
select distinct
|
|
|
|
|
on ("city") "city"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-01-22 22:15:38 +00:00
|
|
|
"ownerId" = any ($1::uuid[])
|
2025-06-02 10:33:08 -04:00
|
|
|
and "visibility" = $2
|
2025-01-09 11:15:41 -05:00
|
|
|
and "deletedAt" is null
|
|
|
|
|
and "city" is not null
|
2024-09-18 08:44:22 -04:00
|
|
|
|
|
|
|
|
-- SearchRepository.getCameraMakes
|
2025-01-09 11:15:41 -05:00
|
|
|
select distinct
|
|
|
|
|
on ("make") "make"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-01-22 22:15:38 +00:00
|
|
|
"ownerId" = any ($1::uuid[])
|
2025-06-02 10:33:08 -04:00
|
|
|
and "visibility" = $2
|
2025-01-09 11:15:41 -05:00
|
|
|
and "deletedAt" is null
|
|
|
|
|
and "make" is not null
|
2024-09-18 08:44:22 -04:00
|
|
|
|
|
|
|
|
-- SearchRepository.getCameraModels
|
2025-01-09 11:15:41 -05:00
|
|
|
select distinct
|
|
|
|
|
on ("model") "model"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_exif"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
|
2025-01-09 11:15:41 -05:00
|
|
|
where
|
2025-01-22 22:15:38 +00:00
|
|
|
"ownerId" = any ($1::uuid[])
|
2025-06-02 10:33:08 -04:00
|
|
|
and "visibility" = $2
|
2025-01-09 11:15:41 -05:00
|
|
|
and "deletedAt" is null
|
|
|
|
|
and "model" is not null
|