Fix plots not generated until after item is posted

This commit is contained in:
ekzyis 2024-03-18 06:43:45 +00:00
parent b8188fbb2e
commit fc0d9d0690
1 changed files with 8 additions and 4 deletions

View File

@ -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;