Split out ability to upload flyover data from pool uploads

Tons of changes here, all in the name of quickly getting to where I can
create test compliance letters.
This commit is contained in:
Eli Ribble 2026-03-02 18:49:02 +00:00
parent 9939434cb3
commit ff2ec0ad14
No known key found for this signature in database
38 changed files with 4204 additions and 233 deletions

View file

@ -1,3 +1,12 @@
INSERT INTO compliance_report_request(created, creator, id, public_id, site_id, site_version)
VALUES (NOW(), :user_id, DEFAULT, :public_id, :site_id, 1);
-- INSERT INTO compliance_report_request (created, creator, public_id, site_id, site_version)
-- SELECT
-- NOW(),
-- 1,
-- generate_alphanumeric_code(8),
-- id,
-- version
-- FROM site;

View file

@ -0,0 +1,40 @@
-- This query is just a one-off to quickly get uploaded data turned into sites.
INSERT INTO site (
address_id,
created,
creator_id,
notes,
organization_id,
owner_name,
parcel_id,
tags,
version
)
SELECT DISTINCT ON (closest_address.id)
closest_address.id AS address_id,
fas.created,
fas.creator_id,
'' AS notes,
fas.organization_id,
'' AS owner_name,
containing_parcel.id AS parcel_id,
''::hstore AS tags,
1 AS version
FROM fileupload.flyover_aerial_service fas
CROSS JOIN LATERAL (
SELECT a.id
FROM address a
ORDER BY a.geom <-> fas.geom
LIMIT 1
) closest_address
CROSS JOIN LATERAL (
SELECT p.id
FROM parcel p
WHERE ST_Contains(p.geometry, fas.geom)
LIMIT 1
) containing_parcel
WHERE fas.geom IS NOT NULL
AND fas.deleted IS NULL
ORDER BY closest_address.id, fas.created ASC -- Keep the earliest created per address
ON CONFLICT (address_id) DO NOTHING; -- Skip if address already has a site