forked from Hay1tsme/artemis
idac: async round info loading
This commit is contained in:
parent
148bef671a
commit
bfbd827dd2
|
@ -101,13 +101,16 @@ class IDACOnlineRounds(BaseData):
|
|||
round_details.c.round_id_in_json == round_id
|
||||
)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
rid = result.fetchone()
|
||||
if rid is None:
|
||||
tmp = {}
|
||||
tmp["round_id_in_json"] = round_id
|
||||
tmp["name"] = round_data["round_event_nm"]
|
||||
tmp["season"] = 2 # default season 2
|
||||
tmp["start_dt"] = round_data["start_dt"]
|
||||
tmp["end_dt"] = round_data["end_dt"]
|
||||
sql = insert(round_details).values(**tmp)
|
||||
self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
return result.lastrowid
|
||||
rid = result.fetchone()
|
||||
return rid["id"]
|
||||
#TODO: get top five players of last round event for Boot/GetConfigData
|
|
@ -4,6 +4,7 @@ from random import choice, randint
|
|||
from typing import Any, Dict, List
|
||||
import json
|
||||
import logging
|
||||
import asyncio
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core.utils import Utils
|
||||
|
@ -61,22 +62,7 @@ class IDACSeason2(IDACBase):
|
|||
)
|
||||
|
||||
# load the user configured round event (only one)
|
||||
self.round_event_id = 0
|
||||
self.round_event = []
|
||||
if self.game_config.round_event.enable:
|
||||
round = self.game_config.round_event.enabled_round
|
||||
if round is not None:
|
||||
if not os.path.exists(f"./titles/idac/data/rounds/season{self.version+1}/{round}.json"):
|
||||
self.logger.warning(f"Round info {round} is enabled but json file does not exist!")
|
||||
else:
|
||||
with open(
|
||||
f"./titles/idac/data/rounds/season{self.version+1}/{round}.json", encoding="UTF-8"
|
||||
) as f:
|
||||
self.logger.debug(f"Loading round info {round}...")
|
||||
tmp = json.load(f)
|
||||
self.round_event_id = self.data.rounds._try_load_round_event(tmp["round_event_id"], tmp)
|
||||
self.round_event.append(self._fix_dates(tmp))
|
||||
self.logger.debug(f"Loaded round id {self.round_event_id}...")
|
||||
asyncio.create_task(self._load_round_event())
|
||||
|
||||
# load the user configured battle gifts (only one)
|
||||
self.battle_gift_event = None
|
||||
|
@ -97,6 +83,25 @@ class IDACSeason2(IDACBase):
|
|||
) as f:
|
||||
self.battle_gift_event = self._fix_dates(json.load(f))
|
||||
|
||||
async def _load_round_event(self):
|
||||
self.round_event_id = 0
|
||||
self.round_event = []
|
||||
if self.game_config.round_event.enable:
|
||||
round = self.game_config.round_event.enabled_round
|
||||
if round is not None:
|
||||
if not os.path.exists(f"./titles/idac/data/rounds/season{self.version+1}/{round}.json"):
|
||||
self.logger.warning(f"Round info {round} is enabled but json file does not exist!")
|
||||
else:
|
||||
with open(
|
||||
f"./titles/idac/data/rounds/season{self.version+1}/{round}.json", encoding="UTF-8"
|
||||
) as f:
|
||||
self.logger.debug(f"Loading round info {round}...")
|
||||
tmp = json.load(f)
|
||||
self.round_event_id = await self.data.rounds._try_load_round_event(tmp["round_event_id"], tmp)
|
||||
self.round_event.append(self._fix_dates(tmp))
|
||||
self.logger.debug(f"Loaded round id for database: {self.round_event_id}...")
|
||||
|
||||
|
||||
async def handle_alive_get_request(self, data: Dict, headers: Dict):
|
||||
return {
|
||||
"status_code": "0",
|
||||
|
|
Loading…
Reference in New Issue