-- NOTE: This file is auto generated by ./sql-generator

-- MapRepository.getAlbumMapMarkers
select
  "id",
  "asset_exif"."latitude" as "lat",
  "asset_exif"."longitude" as "lon",
  "asset_exif"."city",
  "asset_exif"."state",
  "asset_exif"."country"
from
  "asset"
  inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
  and "asset_exif"."latitude" is not null
  and "asset_exif"."longitude" is not null
  inner join "album_asset" on "asset"."id" = "album_asset"."assetId"
where
  "asset"."deletedAt" is null
  and "album_asset"."albumId" = $1
order by
  "fileCreatedAt" desc

-- MapRepository.getMapMarkers
select
  "id",
  "asset_exif"."latitude" as "lat",
  "asset_exif"."longitude" as "lon",
  "asset_exif"."city",
  "asset_exif"."state",
  "asset_exif"."country"
from
  "asset"
  inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
  and "asset_exif"."latitude" is not null
  and "asset_exif"."longitude" is not null
where
  "asset"."deletedAt" is null
  and "asset"."visibility" = $1
  and (
    "ownerId" in ($2)
    or exists (
      select
      from
        "album_asset"
      where
        "asset"."id" = "album_asset"."assetId"
        and "album_asset"."albumId" in ($3)
    )
  )
order by
  "fileCreatedAt" desc
