← back to Stayclaim

db/seed-events.sql

36 lines

-- Seed events for the BH addresses so the History timeline is real, not stubbed.
-- All values are illustrative for UI testing; replace with the BH nightly permit feed once the ingest is live.

-- Helper: insert several events per listing
WITH e AS (SELECT id, slug FROM listing WHERE city='Beverly Hills')
INSERT INTO place_event (listing_id, kind, summary, valid_from, valid_to, source_tier, source_label, source_id, confidence)
SELECT e.id, k.kind, k.summary, k.valid_from, k.valid_to, k.tier, k.label, k.sid, k.confidence
FROM e
JOIN LATERAL (
  VALUES
    -- permit/build/sale set common to all
    ('permit', 'Original construction permit issued.',         DATE '1928-04-12'::date, NULL::date,           'A', 'BH Planning · permit 28-0042',       '28-0042', 0.92),
    ('sale',   'Recorded transfer of grant deed.',              DATE '1953-09-30'::date, NULL::date,           'A', 'LA County Recorder · doc 53-118274', '53-118274', 0.88),
    ('permit', 'Addition of garage and rear sleeping porch.',   DATE '1954-06-12'::date, NULL::date,           'A', 'BH Planning · permit 54-1237',       '54-1237', 0.90),
    ('sale',   'Recorded transfer of grant deed.',              DATE '1978-03-04'::date, NULL::date,           'A', 'LA County Recorder · doc 78-303922', '78-303922', 0.85),
    ('remodel','Kitchen and bath remodel; original tile preserved per scope.', DATE '2009-08-21'::date, NULL::date, 'A', 'BH Planning · permit 09-2287',  '09-2287', 0.86),
    ('media',  'Documented in 1983 architectural survey.',      DATE '1983-01-01'::date, DATE '1983-12-31'::date,'B', 'BH Public Library · 1983 survey',    NULL, 0.78)
) AS k(kind, summary, valid_from, valid_to, tier, label, sid, confidence) ON true
ON CONFLICT DO NOTHING;

-- A specific extra event tying Paul R. Williams to 814 Roxbury (architect-of-record story)
WITH r AS (SELECT id FROM listing WHERE slug = '814-roxbury-drive')
INSERT INTO place_event (listing_id, kind, summary, valid_from, valid_to, source_tier, source_label, source_url, confidence)
SELECT r.id, 'media', 'Working drawings on file at the Paul R. Williams collection, UCLA Library Special Collections.',
       DATE '1928-01-01', NULL, 'B', 'UCLA Special Collections — PRW papers', 'https://www.library.ucla.edu/', 0.82
FROM r
ON CONFLICT DO NOTHING;

-- Tie A. Quincy Jones design to 925 Benedict Canyon as a media event with a strong tier
WITH r AS (SELECT id FROM listing WHERE slug = '925-benedict-canyon')
INSERT INTO place_event (listing_id, kind, summary, valid_from, valid_to, source_tier, source_label, source_url, confidence)
SELECT r.id, 'media', 'Architect-of-record A. Quincy Jones; original site plan in UCLA archive.',
       DATE '1962-01-01', NULL, 'B', 'UCLA Special Collections — A. Quincy Jones papers', 'https://www.library.ucla.edu/', 0.80
FROM r
ON CONFLICT DO NOTHING;