Refactor to collect all books in a category

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
2026-03-01 10:39:09 +00:00
parent 70d0e8d8dd
commit 2b7dd60e0d
3 changed files with 16 additions and 14 deletions

View File

@@ -27,7 +27,7 @@ func init() {
}
func main() {
latestBooks := map[string]*storygraph.Book{}
latestBooks := map[string]*[]storygraph.Book{}
refreshingBooks := true
var lastUpdated *time.Time
@@ -41,9 +41,9 @@ func main() {
}
// Update each category individually with books we have managed to find
for cat, book := range newBookList {
for cat, books := range newBookList {
if b, ok := newBookList[cat]; ok && b != nil {
latestBooks[cat] = book
latestBooks[cat] = books
}
}
now := time.Now()
@@ -60,7 +60,7 @@ func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
type data struct {
Books map[string]*storygraph.Book
Books map[string]*[]storygraph.Book
LastUpdated string
Refreshing bool
}