32 lines
541 B
Go
32 lines
541 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
"log"
|
|
"sevenkeys/database/operations"
|
|
"sevenkeys/scryfall/types"
|
|
)
|
|
|
|
func check(err error) {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
if updatedAtTimestamp.After(cachedFileTimestamp) {
|
|
} else {
|
|
log.Printf("Bulk data has not been updated. Skipping download.")
|
|
}
|
|
|
|
var allCards []types.Card
|
|
allCardsBytes, err := ioutil.ReadFile(ALL_CARDS_CACHE_FILENAME)
|
|
check(err)
|
|
|
|
err = json.Unmarshal(allCardsBytes, &allCards)
|
|
check(err)
|
|
|
|
operations.InsertCards(db, allCards)
|
|
}
|