Ejemplo n.º 1
0
class DataLoader:
    def __init__(self):
        self.db = DBHandle("localhost", "5432", "pubgstatz", "pubgstatz", "pubgstatz")

    def loadUniquePlayers(self):
        return [x for x in self.db.loadData(
            #'select': f"data -> 'data' -> 'attributes' -> 'mapName'",
            #'select': f"data",
            #'where': f"data -> 'data' -> 'attributes' ->> 'mapName' = 'Summerland_Main'"
            #'select': f"data -> 'included' -> "
            f"select participant ->> 'id', participant -> 'attributes' -> 'stats' ->> 'name' from (select json_array_elements(data->'included') from matches) as json_object(participant) where participant ->> 'type' = 'participant'"
            #f"select json_array_elements(data->'included') ->> 'id' as participant from matches"
        )]


    def loadTelemetryEvents(self):
        return self.db.loadData(
            "select data from telemetries limit 1"
        )

    def loadAllParachuteLandings(self, mapName: str):
        query = getQueryString('parachuteLandings.sql')
        query = query.replace('{mapName}', mapName)
        result = self.db.loadData(query)
        return [{
                'matchId': x[0],
                'event': x[1]
            } for x in result
        ]


    def loadAllWinningParachuteLandings(self, mapName: str):
        print('yolo')
Ejemplo n.º 2
0
class LocalDataBasePopulator:
    def __init__(self, relativeFolder: str):
        self.db = DBHandle("localhost", "5432", "pubgstatz", "pubgstatz", "pubgstatz")
        jsonReader = JsonReader(relativeFolder)
        telemetryJsons = jsonReader.telemetryJsons
        for telemetry in telemetryJsons:
            self.db.saveTelemetry(telemetry.matchId, telemetry.json)
Ejemplo n.º 3
0
class App:
    """Application"""
    # Ici les instances statiques des objets de l'application
    urls = Router.urls
    app = web.application(urls, globals())
    render = web.template.render('templates/', base='layout')
    dbHandle = DBHandle()

    def __init__(self):
        pass

    def add_etudiant(self, etudiant):
        """Appel dbHandle app instance"""
        return App.dbHandle.add_etudiant(etudiant)

    def add_cours(self, cours):
        return App.dbHandle.add_cours(cours)

    def add_note(self, note):
        return App.dbHandle.add_note(note)
Ejemplo n.º 4
0
class WebDataBasePopulator:
    def __init__(self):
        self.db = DBHandle("localhost", "5432", "pubgstatz", "pubgstatz", "pubgstatz")
        self.interwebs = Interwebs(token=os.environ.get('PUBG_TOKEN'))

    def saveAllMatchesOfPlayer(self, playerName):
        matchIds = self.interwebs.webGetMatchIdsOfPlayer(playerName)
        for matchId in matchIds:
            if not self.db.matchExists(matchId=matchId):
                print(f'downloading match: {matchId}')
                matchJson = self.interwebs.webGetMatchData(matchId)
                self.db.saveMatch(matchId, matchJson)


    def getTelemetriesForExistingMatches(self):
        status, matches = self.db.loadAllMatches()
        for match in matches:
            if not self.db.telemetryExists(matchId=match['matchId']):
                print(f'downloading telemetry for: {match["matchId"]}')
                matchTelemetry = self.interwebs.webGetFullTelemetryByMatchData(match['matchData'])
                if matchTelemetry:
                    self.db.saveTelemetry(matchId=match['matchId'], telemetry=matchTelemetry)
Ejemplo n.º 5
0
 def __init__(self):
     self.db = DBHandle("localhost", "5432", "pubgstatz", "pubgstatz", "pubgstatz")
     self.interwebs = Interwebs(token=os.environ.get('PUBG_TOKEN'))
Ejemplo n.º 6
0
 def __init__(self):
     self.db = DBHandle("localhost", "5432", "pubgstatz", "pubgstatz", "pubgstatz")