made to suck less, including:
All checks were successful
continuous-integration/drone/push Build is passing

* `make` works again, exporting correct database file path for local dev
* better formatting of durations
* refactored duration math to misc functions
* now tracks and displays score
* displays short-lifetime fp wipeouts in red
This commit is contained in:
2020-03-25 07:50:10 -07:00
parent fe1c4df4f1
commit 0d9ed8874f
9 changed files with 84 additions and 29 deletions

View File

@@ -88,6 +88,7 @@ func (f *Fetcher) StoreFrontPage() error {
Rank: uint(i + 1),
URL: item.URL,
Title: item.Title,
Score: item.Score,
FetchedAt: t,
}
*/
@@ -109,6 +110,7 @@ func (f *Fetcher) StoreFrontPage() error {
HighestRank: uint(i + 1),
Rank: uint(i + 1),
Title: item.Title,
Score: uint(item.Score),
URL: item.URL,
}
f.db.Create(&r)
@@ -116,6 +118,7 @@ func (f *Fetcher) StoreFrontPage() error {
Uint("hnid", uint(id)).
Uint("rank", uint(i+1)).
Str("title", item.Title).
Int("score", item.Score).
Str("url", item.URL).
Msg("HN new story on frontpage")
} else {
@@ -129,10 +132,12 @@ func (f *Fetcher) StoreFrontPage() error {
Uint("hnid", uint(id)).
Uint("oldrank", old.Rank).
Uint("newrank", uint(i+1)).
Int("score", item.Score).
Str("title", item.Title).
Str("url", item.URL).
Msg("HN story rank changed, recording new rank")
old.Rank = uint(i + 1)
old.Score = uint(item.Score)
needSave = true
}
@@ -145,6 +150,12 @@ func (f *Fetcher) StoreFrontPage() error {
old.HighestRank = uint(i + 1)
needSave = true
}
if old.Score != uint(item.Score) {
old.Score = uint(item.Score)
needSave = true
}
if needSave {
f.db.Save(&old)
}