Skip to content

Commit

Permalink
rc5
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Oct 21, 2024
1 parent 3e23e7a commit 7a1dbeb
Show file tree
Hide file tree
Showing 6 changed files with 688 additions and 649 deletions.
10 changes: 3 additions & 7 deletions crud.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from lnbits.db import Database
from lnbits.helpers import insert_query

from .models import Target

db = Database("ext_splitpayments")


async def get_targets(source_wallet: str) -> list[Target]:
rows = await db.fetchall(
return await db.fetchall(
"SELECT * FROM splitpayments.targets WHERE source = :source_wallet",
{"source_wallet": source_wallet},
Target,
)
return [Target(**row) for row in rows]


async def set_targets(source_wallet: str, targets: list[Target]):
Expand All @@ -21,7 +20,4 @@ async def set_targets(source_wallet: str, targets: list[Target]):
{"source_wallet": source_wallet},
)
for target in targets:
await conn.execute(
insert_query("splitpayments.targets", target),
target.dict(),
)
await conn.insert("splitpayments.targets", target)
4 changes: 2 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional

from fastapi import Query
from pydantic import BaseModel
Expand All @@ -19,4 +19,4 @@ class TargetPut(BaseModel):


class TargetPutList(BaseModel):
targets: List[TargetPut]
targets: list[TargetPut]
Loading

0 comments on commit 7a1dbeb

Please sign in to comment.