Skip to content

Commit

Permalink
feat: move cluster status
Browse files Browse the repository at this point in the history
  • Loading branch information
Skelmis committed Jan 6, 2024
1 parent 5fe1fe4 commit 0336371
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 1 addition & 12 deletions suggestions/cogs/help_guild_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ async def show_bot_status(

red_circle = "🔴"
green_circle = "🟢"
url = (
"https://garven.suggestions.gg/cluster/status"
if self.bot.is_prod
else "https://garven.dev.suggestions.gg/cluster/status"
)

embed = disnake.Embed(
timestamp=datetime.datetime.utcnow(),
Expand All @@ -156,13 +151,7 @@ async def show_bot_status(
down_shards: list[str] = [str(i) for i in range(53)]
down_clusters: list[str] = [str(i) for i in range(1, 7)]
avg_bot_latency: list[float] = []
async with aiohttp.ClientSession(
headers={"X-API-KEY": os.environ["GARVEN_API_KEY"]}
) as session:
async with session.get(url) as resp:
data: dict[str, dict | bool] = await resp.json()
if resp.status != 200:
log.error("Something went wrong: %s", data)
data = await self.bot.garven.cluster_status()

if data.pop("partial_response") is not None:
embed.set_footer(text="Partial response")
Expand Down
12 changes: 10 additions & 2 deletions suggestions/garven.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ async def get_shard_info(self, guild_id: int) -> dict[str, str]:
) as resp:
await self._handle_status(resp)
data = await resp.json()
return data

return data

async def get_total_guilds(self) -> int:
async with self._session.get("/aggregate/guilds/count") as resp:
Expand All @@ -76,4 +77,11 @@ async def get_total_guilds(self) -> int:
log.warning("get_total_guilds returned a partial response")
raise PartialResponse

return data["statistic"]
return data["statistic"]

async def cluster_status(self) -> dict:
async with self._session.get("/cluster/status") as resp:
await self._handle_status(resp)
data = await resp.json()

return data

0 comments on commit 0336371

Please sign in to comment.