Skip to content

Commit 055187a

Browse files
committed
refactor(afk.py): remove debug logging for AFK entry checks
Remove unnecessary debug logging from the AFK controller and utility module. The logs for fetching all AFK entries and expired entries are eliminated to reduce noise in the log output. This change aims to streamline the logging process by focusing on essential information only, improving performance and readability of logs during AFK expiration checks.
1 parent afc7a4e commit 055187a

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

src/tux/database/controllers/afk.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from datetime import UTC, datetime
1111
from typing import TYPE_CHECKING, Any
1212

13-
from loguru import logger
14-
1513
from tux.database.controllers.base import BaseController
1614
from tux.database.models import AFK
1715

@@ -282,25 +280,11 @@ async def get_expired_afk_members(self, guild_id: int) -> list[AFK]:
282280
# Database stores naive UTC datetimes, use naive for comparison
283281
now = datetime.now(UTC).replace(tzinfo=None)
284282

285-
# First, get ALL AFK entries for this guild to debug
286-
all_entries = await self.find_all(filters=AFK.guild_id == guild_id)
287-
logger.debug(
288-
f"Total AFK entries in guild {guild_id}: {len(all_entries)}",
289-
)
290-
for entry in all_entries:
291-
logger.debug(
292-
f"AFK entry: member={entry.member_id}, until={entry.until}, "
293-
f"perm_afk={entry.perm_afk}, enforced={entry.enforced}, "
294-
f"expired={entry.until < now if entry.until else 'N/A'}",
295-
)
296-
297-
expired = await self.find_all(
283+
return await self.find_all(
298284
filters=(
299285
(AFK.guild_id == guild_id)
300286
& (AFK.perm_afk == False) # noqa: E712 - Temporary AFK only
301287
& (AFK.until.is_not(None)) # type: ignore[attr-defined]
302288
& (AFK.until < now) # type: ignore[arg-type]
303289
),
304290
)
305-
logger.debug(f"Expired AFK entries found: {len(expired)}")
306-
return expired

src/tux/modules/utility/afk.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,15 @@ async def handle_afk_expiration(self) -> None:
422422
"""Check AFK database at a regular interval, remove AFK from users with an entry that has expired."""
423423
# Skip AFK expiration processing during maintenance mode
424424
if self.bot.maintenance_mode:
425-
logger.debug("Skipping AFK expiration check (maintenance mode)")
426425
return
427426

428-
logger.debug("Running AFK expiration handler")
429427
for guild in self.bot.guilds:
430428
expired_entries = await self._get_expired_afk_entries(guild.id)
431429

432430
if expired_entries:
433431
logger.info(
434432
f"Processing {len(expired_entries)} expired AFK entries in {guild.name}",
435433
)
436-
else:
437-
logger.debug(f"No expired AFK entries found in {guild.name}")
438434

439435
for entry in expired_entries:
440436
# Re-check if entry still exists (could have been removed by user message)

0 commit comments

Comments
 (0)