Make class names singular
This commit is contained in:
parent
7066f4d11a
commit
010d59caac
|
@ -1,5 +1,5 @@
|
|||
from . import db
|
||||
from .models import Donations, Services
|
||||
from .models import Donation, Service
|
||||
|
||||
from ..satspay.crud import delete_charge
|
||||
|
||||
|
@ -32,7 +32,7 @@ async def create_donation(
|
|||
amount: float,
|
||||
service: int,
|
||||
posted: bool = False,
|
||||
) -> Donations:
|
||||
) -> Donation:
|
||||
await db.execute(
|
||||
"""
|
||||
INSERT INTO Donations (
|
||||
|
@ -81,7 +81,7 @@ async def create_service(
|
|||
wallet: str,
|
||||
servicename: str,
|
||||
onchain: str = None,
|
||||
) -> Services:
|
||||
) -> Service:
|
||||
result = await db.execute(
|
||||
"""
|
||||
INSERT INTO Services (
|
||||
|
@ -110,12 +110,12 @@ async def create_service(
|
|||
return service
|
||||
|
||||
|
||||
async def get_service(service_id: int) -> Optional[Services]:
|
||||
async def get_service(service_id: int) -> Optional[Service]:
|
||||
row = await db.fetchone(
|
||||
"SELECT * FROM Services WHERE id = ?",
|
||||
(service_id,)
|
||||
)
|
||||
return Services.from_row(row) if row else None
|
||||
return Service.from_row(row) if row else None
|
||||
|
||||
|
||||
async def authenticate_service(service_id, code, redirect_uri):
|
||||
|
@ -160,17 +160,17 @@ async def delete_service(service_id: int) -> None:
|
|||
await delete_donation(row["id"])
|
||||
|
||||
|
||||
async def get_donation(donation_id: str) -> Optional[Donations]:
|
||||
async def get_donation(donation_id: str) -> Optional[Donation]:
|
||||
row = await db.fetchone(
|
||||
"SELECT * FROM Donations WHERE id = ?",
|
||||
(donation_id,)
|
||||
)
|
||||
return Donations.from_row(row) if row else None
|
||||
return Donation.from_row(row) if row else None
|
||||
|
||||
|
||||
async def delete_donation(donation_id: str) -> None:
|
||||
await db.execute(
|
||||
"DELETE FROM Donatoins WHERE id = ?",
|
||||
"DELETE FROM Donations WHERE id = ?",
|
||||
(donation_id,)
|
||||
)
|
||||
await delete_charge(donation_id)
|
||||
|
|
|
@ -2,7 +2,7 @@ from sqlite3 import Row
|
|||
from typing import NamedTuple, Optional
|
||||
|
||||
|
||||
class Donations(NamedTuple):
|
||||
class Donation(NamedTuple):
|
||||
id: str
|
||||
name: str
|
||||
cur_code: str
|
||||
|
@ -12,11 +12,11 @@ class Donations(NamedTuple):
|
|||
posted: bool
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row) -> "Donations":
|
||||
def from_row(cls, row: Row) -> "Donation":
|
||||
return cls(**dict(row))
|
||||
|
||||
|
||||
class Services(NamedTuple):
|
||||
class Service(NamedTuple):
|
||||
id: int
|
||||
twitchuser: str
|
||||
client_id: str
|
||||
|
@ -28,5 +28,5 @@ class Services(NamedTuple):
|
|||
token: Optional[int]
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row) -> "Services":
|
||||
def from_row(cls, row: Row) -> "Service":
|
||||
return cls(**dict(row))
|
||||
|
|
Loading…
Reference in New Issue
Block a user