Update all the shit
This commit is contained in:
@ -25,6 +25,7 @@ type MapScore struct {
|
||||
CaptureID int64 `bun:"capture_id"`
|
||||
StartTime time.Time `bun:",notnull"`
|
||||
Map string `bun:",notnull"`
|
||||
Counted bool `bun:",notnull"`
|
||||
ScoreList []Score `bun:"rel:has-many,join:id=mapscore_id"`
|
||||
}
|
||||
|
||||
@ -60,8 +61,15 @@ func (msl MapScoreList) BuildTable() *ResultTable {
|
||||
|
||||
rt.Header = append(rt.Header, make([]ResultTableHeader, len(msl))...)
|
||||
|
||||
for mapIndex, mapScore := range msl {
|
||||
reversedIndex := len(msl) - 1 - mapIndex
|
||||
filteredMapScores := []MapScore{}
|
||||
for _, ms := range msl {
|
||||
if ms.Counted {
|
||||
filteredMapScores = append(filteredMapScores, ms)
|
||||
}
|
||||
}
|
||||
|
||||
for mapIndex, mapScore := range filteredMapScores {
|
||||
reversedIndex := len(filteredMapScores) - 1 - mapIndex
|
||||
|
||||
rt.Header[reversedIndex+2] = ResultTableHeader{
|
||||
Title: mapScore.Map,
|
||||
@ -73,7 +81,7 @@ func (msl MapScoreList) BuildTable() *ResultTable {
|
||||
rt.Rows = append(rt.Rows, ResultTableRow{
|
||||
Name: score.Name,
|
||||
Total: 0,
|
||||
Individual: make([]int, len(msl)),
|
||||
Individual: make([]int, len(filteredMapScores)),
|
||||
})
|
||||
|
||||
userMapRows[score.Name] = len(rt.Rows) - 1
|
||||
|
||||
@ -18,6 +18,7 @@ type Persistence interface {
|
||||
DeleteCapture(context.Context, int64) error
|
||||
|
||||
GetRecentMapScore(context.Context, int64) (*MapScore, error)
|
||||
SetMapScoreConted(context.Context, int64, bool) error
|
||||
CreateMapScore(context.Context, *MapScore) error
|
||||
|
||||
CreateOrUpdateScores(context.Context, []Score) error
|
||||
@ -105,6 +106,14 @@ func (s *SQLitePersistence) GetRecentMapScore(ctx context.Context, captureid int
|
||||
return &scores[0], nil
|
||||
}
|
||||
|
||||
func (s *SQLitePersistence) SetMapScoreConted(ctx context.Context, mapscoreid int64, counted bool) error {
|
||||
mapscore := MapScore{
|
||||
ID: mapscoreid,
|
||||
}
|
||||
_, err := s.db.NewUpdate().Model(&mapscore).WherePK().Set("counted = ?", counted).Exec(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SQLitePersistence) CreateMapScore(ctx context.Context, mapscore *MapScore) error {
|
||||
_, err := s.db.NewInsert().Model(mapscore).Exec(ctx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user