From 99817645b2ece9de8f8c057db356c5ecaa3c681a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Wed, 25 Sep 2024 11:14:16 +0200 Subject: [PATCH] feat: add nostr compat --- crud.py | 2 ++ migrations.py | 18 ++++++++++++++++++ models.py | 4 +++- views_api.py | 2 -- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crud.py b/crud.py index b08f0ea..a70c81e 100644 --- a/crud.py +++ b/crud.py @@ -80,6 +80,7 @@ async def create_appointment( end_time=data.end_time, schedule=schedule_id, paid=False, + created_at=datetime.now(), ) await db.execute( insert_query("lncalendar.appointment", appointment), @@ -150,6 +151,7 @@ async def create_unavailable_time(data: CreateUnavailableTime) -> UnavailableTim start_time=data.start_time, end_time=data.end_time or data.start_time, schedule=data.schedule, + created_at=datetime.now(), ) await db.execute( insert_query("lncalendar.unavailable", unavailable_time), diff --git a/migrations.py b/migrations.py index ff16927..27e3f9a 100644 --- a/migrations.py +++ b/migrations.py @@ -51,3 +51,21 @@ async def m001_initial(db): ); """ ) + + +async def m002_rename_time_to_created_at(db): + """ + Rename time to created_at in the unavailability table. + """ + await db.execute( + """ + ALTER TABLE lncalendar.unavailable + RENAME COLUMN time TO created_at; + """ + ) + await db.execute( + """ + ALTER TABLE lncalendar.appointment + RENAME COLUMN time TO created_at; + """ + ) diff --git a/models.py b/models.py index a6b7ed9..3ac1d84 100644 --- a/models.py +++ b/models.py @@ -1,3 +1,4 @@ +from datetime import datetime from typing import Optional from fastapi import Query @@ -49,6 +50,7 @@ class UnavailableTime(BaseModel): start_time: str end_time: str schedule: str + created_at: datetime class Appointment(BaseModel): @@ -60,4 +62,4 @@ class Appointment(BaseModel): end_time: str schedule: str paid: bool - time: int + created_at: datetime diff --git a/views_api.py b/views_api.py index 1f50e1e..f5b7d75 100644 --- a/views_api.py +++ b/views_api.py @@ -1,9 +1,7 @@ -import sched from http import HTTPStatus from fastapi import APIRouter, Depends, Query from fastapi.exceptions import HTTPException - from lnbits.core.crud import get_standalone_payment, get_user from lnbits.core.models import User, WalletTypeInfo from lnbits.core.services import create_invoice