fixed SIGSEGV if no messages are present

This commit is contained in:
2022-01-29 20:21:49 +01:00
parent b0870cd927
commit 2f15560d84
2 changed files with 9 additions and 4 deletions

View File

@@ -511,15 +511,17 @@ func (p *DemoParser) parseWorker() {
}
}
bulk := make([]*ent.MessagesCreate, len(tMatchPlayer.Edges.Messages))
bulk := make([]*ent.MessagesCreate, 0)
for _, msg := range tMatchPlayer.Edges.Messages {
bulk = append(bulk, p.db.Messages.Create().SetMessage(msg.Message).SetAllChat(msg.AllChat).SetMatchPlayer(tMatchPlayer))
}
if len(bulk) > 0 {
err = p.db.Messages.CreateBulk(bulk...).Exec(context.Background())
if err != nil {
log.Warningf("[DP] Failure adding messages to database: %v", err)
}
}
}
log.Infof("[DP] parsed match %d (took %s/%s)", demo.MatchId, downloadTime, time.Since(startTime))

View File

@@ -1046,6 +1046,9 @@ func main() {
router.HandleFunc(`/match/{id:\d{19}}/rounds`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/match/{id:\d{19}}/rounds`, getMatchRounds).Methods(http.MethodGet)
router.HandleFunc(`/match/{id:\d{19}}/rounds`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/match/{id:\d{19}}/rounds`, getMatchRounds).Methods(http.MethodGet)
router.HandleFunc(`/matches`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/matches`, getMatches).Methods(http.MethodGet)