Refactor to collect all books in a category
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
8
main.go
8
main.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user