33 lines
589 B
Go
33 lines
589 B
Go
package update
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"sevenkeys/logic"
|
|
"sevenkeys/logic/scryfall"
|
|
)
|
|
|
|
func UpdateScryfallData(db *sql.DB) {
|
|
fmt.Println("Checking for updates...")
|
|
bulkData, err := scryfall.GetBulkDataByType(scryfall.BulkDataTypeAllCards)
|
|
logic.Check(err)
|
|
|
|
needsUpdate, err := logic.CheckForUpdates(db, bulkData)
|
|
logic.Check(err)
|
|
|
|
if !needsUpdate {
|
|
fmt.Println("No update required.")
|
|
return
|
|
}
|
|
|
|
logic.CreateCacheDirectories()
|
|
|
|
err = logic.UpdateSets(db)
|
|
logic.Check(err)
|
|
|
|
err = logic.UpdateCards(db, bulkData)
|
|
logic.Check(err)
|
|
|
|
fmt.Println("Update finished.")
|
|
}
|