[feat] add select ap_type command
All checks were successful
/ run-pytest (push) Successful in 1m6s

This commit is contained in:
SouthFox 2024-03-11 22:35:32 +08:00
parent 523cb1f467
commit 253970094b
2 changed files with 35 additions and 0 deletions

12
app/hysql.hy Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env hy
(import app [models])
(import app.database [async_session])
(import sqlalchemy [select])
(import pprint [pprint])
(defn/a selete_object
[db ap_type]
(.all (await (.scalars db
(.where (select models.InboxObject)
(= models.InboxObject.ap_type ap_type))))))

View file

@ -202,3 +202,26 @@ def send_note(ctx):
print("Done!") print("Done!")
asyncio.run(_dodo()) asyncio.run(_dodo())
@task
def get_object(ctx, ap_type):
import hy
from app.database import async_session
from app.hysql import selete_object
from pprint import pprint
async def _dodo():
async with async_session() as db_session: #type: ignore
return await selete_object(
db_session,
ap_type
)
res = asyncio.run(_dodo())
for ap_object in res:
print("=====")
print(ap_object.id )
print(ap_object.ap_id)
pprint(ap_object.ap_object)