Esempio n. 1
0
    def __init__(self, client_id: str = "", client_secret: str = ""):
        super().__init__()

        # credentials
        self.client_id = client_id or os.getenv("WCL_CLIENT_ID")
        self.client_secret = client_secret or os.getenv("WCL_CLIENT_SECRET")
        self.headers: typing.Dict[str, str] = {}

        logger.info("NEW CLIENT: %s", self.client_id)
        self._num_queries = 0
Esempio n. 2
0
    async def load_fights(self, fight_ids: typing.List[int], player_ids: typing.List[int]):
        await self.client.ensure_auth()

        if not self.fights:
            await self.load_summary()

        for ids in utils.chunks(fight_ids, 10):
            logger.info(f"loading fights: {ids}")
            tasks = [self.load_fight(fight_id=fight_id, player_ids=player_ids) for fight_id in ids]
            await asyncio.gather(*tasks)
Esempio n. 3
0
    async def load_players(self):
        """Load the Casts for all missing fights."""
        actors_to_load: typing.List[BaseActor] = self.players

        # make sure the first report has the boss added
        if self.fights:
            first_fight = self.fights[0]
            actors_to_load += [first_fight.boss]

        actors_to_load = [actor for actor in actors_to_load if not actor.casts]

        logger.info(f"load {len(actors_to_load)} players")
        if not actors_to_load:
            return

        await self.load_many(actors_to_load, chunk_size=5)
Esempio n. 4
0
async def load_spec_ranking(spec_slug: str,
                            boss_slug: str,
                            difficulty: str = "mythic",
                            metric: str = "",
                            limit: int = 50,
                            clear: bool = False):
    logger.info("START | %s | spec=%s | boss=%s | limit=%d | clear=%s",
                difficulty, spec_slug, boss_slug, limit, clear)

    spec_ranking = warcraftlogs_ranking.SpecRanking.get_or_create(
        boss_slug=boss_slug,
        spec_slug=spec_slug,
        difficulty=difficulty,
        metric=metric,
    )
    await spec_ranking.load(limit=limit, clear_old=clear)
    spec_ranking.save()

    logger.info("DONE | %s | spec=%s | boss=%s | limit=%d | clear=%s",
                difficulty, spec_slug, boss_slug, limit)
    return "done"
Esempio n. 5
0
    async def load(self, limit=50, clear_old=False):
        """Get Top Ranks for a given boss and spec."""
        logger.info(
            f"{self.boss.name} vs. {self.spec.name} {self.spec.wow_class.name} START | limit={limit} | clear_old={clear_old}"
        )

        if clear_old:
            self.reports = []

        # refresh the ranking data
        await self.load_rankings()
        self.reports = self.sort_reports(self.reports)

        # enforce limit
        limit = limit or -1
        self.reports = self.reports[:limit]

        # load the fights/players/casts
        await self.load_players()

        self.updated = datetime.datetime.utcnow()
        logger.info("done")