feat(schedule): Complete schedule cmd impl.

This commit is contained in:
2023-09-30 12:13:50 +03:00
parent ca963ee8b1
commit 1f92957393
2 changed files with 199 additions and 12 deletions

View File

@@ -2,9 +2,11 @@ import asyncio
import itertools
import datetime as dt
from . import logger
from . import logger, babel
from utils.ratelimits import Bucket
_p, _np = babel._p, babel._np
def time_to_slotid(time: dt.datetime) -> int:
"""
@@ -71,3 +73,18 @@ async def limit_concurrency(aws, limit):
while done:
yield done.pop()
logger.debug(f"Completed {count} tasks")
def format_until(t, distance):
if distance:
return t(_np(
'ui:schedule|format_until|positive',
"in <1 hour",
"in {number} hours",
distance
)).format(number=distance)
else:
return t(_p(
'ui:schedule|format_until|now',
"right now!"
))