Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target-version = "py311"
line-length = 220
line-length = 88
indent-width = 4

extend-exclude = [
Expand Down
4 changes: 3 additions & 1 deletion tle/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def setup():
level=logging.INFO,
handlers=[
logging.StreamHandler(),
TimedRotatingFileHandler(constants.LOG_FILE_PATH, when='D', backupCount=3, utc=True),
TimedRotatingFileHandler(
constants.LOG_FILE_PATH, when='D', backupCount=3, utc=True
),
],
)

Expand Down
12 changes: 9 additions & 3 deletions tle/cogs/cache_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class CacheControl(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.group(brief='Commands to force reload of cache', invoke_without_command=True)
@commands.group(
brief='Commands to force reload of cache', invoke_without_command=True
)
@commands.has_role(constants.TLE_ADMIN)
async def cache(self, ctx):
await ctx.send_help('cache')
Expand Down Expand Up @@ -61,7 +63,9 @@ async def ratingchanges(self, ctx, contest_id='missing'):
await ctx.send('This may take a while')
count = await cf_common.cache2.rating_changes_cache.fetch_missing_contests()
else:
count = await cf_common.cache2.rating_changes_cache.fetch_contest(contest_id)
count = await cf_common.cache2.rating_changes_cache.fetch_contest(
contest_id
)
await ctx.send(f'Done, fetched {count} changes and recached handle ratings')

@cache.command(usage='contest_id|all')
Expand All @@ -79,7 +83,9 @@ async def problemsets(self, ctx, contest_id):
contest_id = int(contest_id)
except ValueError:
return
count = await cf_common.cache2.problemset_cache.update_for_contest(contest_id)
count = await cf_common.cache2.problemset_cache.update_for_contest(
contest_id
)
await ctx.send(f'Done, fetched {count} problems')


Expand Down
257 changes: 199 additions & 58 deletions tle/cogs/codeforces.py

Large diffs are not rendered by default.

333 changes: 251 additions & 82 deletions tle/cogs/contests.py

Large diffs are not rendered by default.

30 changes: 26 additions & 4 deletions tle/cogs/deactivated/cses.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def __init__(self, bot):
async def on_ready(self):
self._cache_data.start()

@tasks.task_spec(name='ProblemsetCacheUpdate', waiter=tasks.Waiter.fixed_delay(30 * 60))
@tasks.task_spec(
name='ProblemsetCacheUpdate', waiter=tasks.Waiter.fixed_delay(30 * 60)
)
async def _cache_data(self, _):
await self._reload()

Expand Down Expand Up @@ -104,14 +106,34 @@ def shortest_individual(self, handles):

@commands.command(brief='Shows compiled CSES leaderboard', usage='[handles...]')
async def cses(self, ctx, *handles: str):
"""Shows compiled CSES leaderboard. If handles are given, leaderboard will contain only those indicated handles, otherwise leaderboard will contain overall top ten."""
"""Shows compiled CSES leaderboard.

If handles are given, leaderboard will contain only those indicated
handles, otherwise leaderboard will contain overall top ten.
"""
if not handles:
await ctx.send('```\nFastest\n' + self.fastest + '\n\n' + 'Shortest\n' + self.shortest + '\n' + '```')
await ctx.send(
'```\nFastest\n'
+ self.fastest
+ '\n\n'
+ 'Shortest\n'
+ self.shortest
+ '\n'
+ '```'
)
elif len(handles) > 10:
await ctx.send('```Please indicate at most 10 users```')
else:
handles = set(handles)
await ctx.send('```\nFastest\n' + self.fastest_individual(handles) + '\n\n' + 'Shortest\n' + self.shortest_individual(handles) + '\n' + '```')
await ctx.send(
'```\nFastest\n'
+ self.fastest_individual(handles)
+ '\n\n'
+ 'Shortest\n'
+ self.shortest_individual(handles)
+ '\n'
+ '```'
)

@commands.command(brief='Force update the CSES leaderboard')
async def _updatecses(self, ctx):
Expand Down
Loading