Added estimation for next pack time (need to check what happened on 10 opening)
This commit is contained in:
parent
933b06eaf3
commit
5e5a56009c
|
|
@ -12,3 +12,19 @@ class EveryRunRotator:
|
|||
self.rotate = False
|
||||
return True
|
||||
return False
|
||||
|
||||
class HumanReadable:
|
||||
@staticmethod
|
||||
def seconds_to_human(seconds: int|float):
|
||||
output = ""
|
||||
h = seconds // 3600
|
||||
m = (seconds - h * 3600) // 60
|
||||
s = seconds - (h * 3600) - (m * 60)
|
||||
|
||||
if h > 0:
|
||||
output += f"{int(h)} hours "
|
||||
if m > 0 or h > 0:
|
||||
output += f"{int(m)} min "
|
||||
output += f"{int(s):02}s"
|
||||
|
||||
return output
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
import httpx
|
||||
from supabase import create_client, Client
|
||||
from loguru import logger
|
||||
import datetime
|
||||
from ..lib.supabase_cookie import get_auth_cookies
|
||||
from ..lib.utils import HumanReadable as hr
|
||||
# supabase ?
|
||||
# https://cyrxjeppjqsxxjayfrur.supabase.co/auth/v1/token?grant_type=password
|
||||
# https://cyrxjeppjqsxxjayfrur.supabase.co/auth/v1/user
|
||||
|
|
@ -67,3 +69,25 @@ class WikiMastersClient:
|
|||
"sync_profile_packs", {"user_id": session.user.id}
|
||||
).execute()
|
||||
self.logger.info("info sync: {}", response)
|
||||
|
||||
d = response.data[0]
|
||||
_id = d["id"]
|
||||
_username = d["username"]
|
||||
_packs_remaining = d["packs_remaining"]
|
||||
_packs_last_regen_at = datetime.datetime.fromisoformat(
|
||||
d["packs_last_regen_at"]
|
||||
)
|
||||
|
||||
# Does this math still works when we are opening the 9th pack ?
|
||||
self.logger.info(
|
||||
"Next pack is in {}",
|
||||
hr.seconds_to_human(
|
||||
(
|
||||
datetime.timedelta(minutes=10)
|
||||
- (
|
||||
datetime.datetime.now(tz=datetime.timezone.utc)
|
||||
- _packs_last_regen_at
|
||||
)
|
||||
).total_seconds()
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue