Add link to chart
* Added SQL file to export CSV * Updated plot.py to close figures due to RuntimeWarning shown * hnbot now includes link to chart in comment * charts are generated and copied to files.ekzyis.com using a cronjob
This commit is contained in:
parent
c993978384
commit
00d3d759ac
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
cd /home/ekzyis/hnbot
|
||||||
|
sqlite3 hnbot.sqlite3 < hacker_news.csv.sql
|
||||||
|
venv/bin/python plot.py
|
||||||
|
mv hn_*.png plots/
|
||||||
|
rsync plots/* vps:/var/www/files/public/hn/
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
.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;
|
3
plot.py
3
plot.py
|
@ -58,3 +58,6 @@ for [hn_id], group in grouped:
|
||||||
|
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
plt.savefig(f'hn_{hn_id}.png')
|
plt.savefig(f'hn_{hn_id}.png')
|
||||||
|
plt.close()
|
||||||
|
|
||||||
|
print(f'Saved hn_{hn_id}.png')
|
||||||
|
|
3
sn.go
3
sn.go
|
@ -84,7 +84,8 @@ func PostStoryToStackerNews(story *Story, options PostStoryOptions) (int, error)
|
||||||
SendStackerNewsEmbedToDiscord(story.Title, parentId)
|
SendStackerNewsEmbedToDiscord(story.Title, parentId)
|
||||||
|
|
||||||
comment := fmt.Sprintf(
|
comment := fmt.Sprintf(
|
||||||
"This link was posted by [%s](%s) %s on [HN](%s). It received %d points and %d comments.",
|
"This link was posted by [%s](%s) %s on [HN](%s). It received %d points and %d comments.\n\n"+
|
||||||
|
fmt.Sprintf("https://files.ekzyis.com/public/hn/hn_%d.png", story.ID),
|
||||||
story.By,
|
story.By,
|
||||||
HackerNewsUserLink(story.By),
|
HackerNewsUserLink(story.By),
|
||||||
humanize.Time(time.Unix(int64(story.Time), 0)),
|
humanize.Time(time.Unix(int64(story.Time), 0)),
|
||||||
|
|
Loading…
Reference in New Issue