From fc0d9d069024939e27a7a7417e6dfd0f7d99f987 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Mon, 18 Mar 2024 06:43:45 +0000 Subject: [PATCH] Fix plots not generated until after item is posted --- hacker_news.csv.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hacker_news.csv.sql b/hacker_news.csv.sql index 1ff8bd8..81ddbef 100644 --- a/hacker_news.csv.sql +++ b/hacker_news.csv.sql @@ -1,7 +1,11 @@ .headers on .mode csv .output hacker_news.csv -SELECT id, created_at, time, title, url, author, ndescendants, score, rank -FROM hn_items -WHERE id IN (SELECT hn_id FROM sn_items) -ORDER BY id, created_at DESC; +SELECT hn.id, hn.created_at, hn.time, hn.title, hn.url, hn.author, hn.ndescendants, hn.score, hn.rank +FROM ( + SELECT id, MAX(created_at) AS created_at FROM hn_items + WHERE rank = 1 AND length(title) >= 5 + GROUP BY id + ORDER BY time ASC +) t JOIN hn_items hn ON t.id = hn.id +ORDER BY hn.id, hn.created_at DESC;