Skip to content

Commit

Permalink
type defs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Sep 24, 2023
1 parent 7bf13db commit 0e0118d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/repositories/ingame_logins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import textwrap
from datetime import datetime
from typing import Any
from typing import cast
from typing import TypedDict

Expand Down Expand Up @@ -54,7 +55,7 @@ async def create(
INSERT INTO ingame_logins (userid, ip, osu_ver, osu_stream, datetime)
VALUES (:userid, :ip, :osu_ver, :osu_stream, NOW())
"""
params = {
params: dict[str, Any] = {
"userid": user_id,
"ip": ip,
"osu_ver": osu_ver,
Expand All @@ -76,16 +77,14 @@ async def create(
return cast(IngameLogin, dict(ingame_login._mapping))


async def fetch_one(
id: int,
) -> IngameLogin | None:
async def fetch_one(id: int) -> IngameLogin | None:
"""Fetch a login entry from the database."""
query = f"""\
SELECT {READ_PARAMS}
FROM ingame_logins
WHERE id = :id
"""
params = {
params: dict[str, Any] = {
"id": id,
}
ingame_login = await app.state.services.database.fetch_one(query, params)
Expand All @@ -104,7 +103,7 @@ async def fetch_count(
WHERE userid = COALESCE(:userid, userid)
AND ip = COALESCE(:ip, ip)
"""
params = {
params: dict[str, Any] = {
"userid": user_id,
"ip": ip,
}
Expand All @@ -130,7 +129,7 @@ async def fetch_many(
AND osu_ver = COALESCE(:osu_ver, osu_ver)
AND osu_stream = COALESCE(:osu_stream, osu_stream)
"""
params = {
params: dict[str, Any] = {
"userid": user_id,
"ip": ip,
"osu_ver": osu_ver,
Expand Down

0 comments on commit 0e0118d

Please sign in to comment.