From f468195899e88c1b14611523a7525a4d65965e85 Mon Sep 17 00:00:00 2001 From: Jesse Mortenson Date: Fri, 1 Nov 2024 08:55:07 -0500 Subject: [PATCH] Querying scrape data: add additional helper views --- docs/data/query-scraper-output-data.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/data/query-scraper-output-data.md b/docs/data/query-scraper-output-data.md index 0ec984f..15c29a0 100644 --- a/docs/data/query-scraper-output-data.md +++ b/docs/data/query-scraper-output-data.md @@ -135,6 +135,12 @@ FROM vote_events; CREATE VIEW events AS SELECT * FROM read_json('event*.json'); +CREATE VIEW event_documents AS +SELECT name AS event_name, _id AS event_id, unnest(documents, recursive := true) +FROM events; +CREATE VIEW event_document_links AS +SELECT event_name, event_id, note AS document_note, unnest(links, recursive := true) +FROM event_documents; CREATE VIEW event_media AS SELECT name AS event_name, _id AS event_id, unnest(media) FROM events; @@ -218,7 +224,7 @@ GROUP BY 1; #### Vote Events over time (by month) ```sql -SELECT date_trunc('month', start_date), COUNT(*) +SELECT date_trunc('month', start_date::timestamp), COUNT(*) FROM vote_events GROUP BY 1, ORDER BY 1;