// Fetch all Heroes from the Steam API and save them to the DB. func GetHeroes(db *sql.DB, api webapi.WebApi) (err error) { lang := "en_us" heroes, err := api.GetHeroes(lang) if err != nil { return err } err = models.SaveHeroes(db, heroes, lang) if err != nil { return err } return err }
// Fetch all Game Items from the Steam API and save them to the DB. func GetGameItems(db *sql.DB, api webapi.WebApi) (err error) { lang := "en_us" items, err := api.GetGameItems(lang) if err != nil { return err } err = models.SaveGameItems(db, items, lang) if err != nil { return err } return err }
// Fetch Matches in Sequence from the Steam API and save them to the DB. func ContMatchHistorySeq(db *sql.DB, api webapi.WebApi, lastSeqNum *int) (err error) { // Get Matches from API matches, err := api.GetMatchHistorySeq(lastSeqNum) if err != nil { return err } // Filter Matches for Ranked and Tournament /*for i := len(matches) - 1; i >= 0; i-- { switch matches[i].LobbyType { case 2: // Tournament case 7: // Ranked Match default: matches = append(matches[:i], matches[i+1:]...) } }*/ // Save Matches to DB err = models.SaveSeqMatches(db, matches) if err != nil { return err } if len(matches) > 0 { lastItem := len(matches) - 1 *lastSeqNum = matches[lastItem].MatchSeqNum } return err }