code.vegaprotocol.io/vega@v0.79.0/datanode/service/game_scores.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package service 17 18 import ( 19 "context" 20 21 "code.vegaprotocol.io/vega/datanode/entities" 22 "code.vegaprotocol.io/vega/logging" 23 ) 24 25 type gameScoreStore interface { 26 ListPartyScores( 27 ctx context.Context, 28 gameIDs []entities.GameID, 29 partyIDs []entities.PartyID, 30 teamIDs []entities.TeamID, 31 epochFromID *uint64, 32 epochToID *uint64, 33 pagination entities.CursorPagination, 34 ) ([]entities.GamePartyScore, entities.PageInfo, error) 35 ListTeamScores( 36 ctx context.Context, 37 gameIDs []entities.GameID, 38 teamIDs []entities.TeamID, 39 epochFromID *uint64, 40 epochToID *uint64, 41 pagination entities.CursorPagination, 42 ) ([]entities.GameTeamScore, entities.PageInfo, error) 43 } 44 45 type GameScore struct { 46 store gameScoreStore 47 } 48 49 func NewGameScore(store gameScoreStore, log *logging.Logger) *GameScore { 50 return &GameScore{ 51 store: store, 52 } 53 } 54 55 func (gs *GameScore) ListPartyScores( 56 ctx context.Context, 57 gameIDs []entities.GameID, 58 partyIDs []entities.PartyID, 59 teamIDs []entities.TeamID, 60 epochFromID *uint64, 61 epochToID *uint64, 62 pagination entities.CursorPagination, 63 ) ([]entities.GamePartyScore, entities.PageInfo, error) { 64 return gs.store.ListPartyScores(ctx, gameIDs, partyIDs, teamIDs, epochFromID, epochToID, pagination) 65 } 66 67 func (gs *GameScore) ListTeamScores( 68 ctx context.Context, 69 gameIDs []entities.GameID, 70 teamIDs []entities.TeamID, 71 epochFromID *uint64, 72 epochToID *uint64, 73 pagination entities.CursorPagination, 74 ) ([]entities.GameTeamScore, entities.PageInfo, error) { 75 return gs.store.ListTeamScores(ctx, gameIDs, teamIDs, epochFromID, epochToID, pagination) 76 }