Field live_at is nulluble

pull/931/head
kompotkot 2023-12-07 09:57:17 +00:00
rodzic 4746d5ceec
commit 6b749b5fef
4 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -1,8 +1,8 @@
"""Live at for metatx
Revision ID: 4f05d212ea49
Revises: 040f2dfde5a5
Create Date: 2023-10-03 10:00:09.730620
Revision ID: 6d07739cb13e
Revises: cc80e886e153
Create Date: 2023-12-06 14:33:04.814144
"""
from alembic import op
@ -10,15 +10,15 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4f05d212ea49'
down_revision = '040f2dfde5a5'
revision = '6d07739cb13e'
down_revision = 'cc80e886e153'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('call_requests', sa.Column('live_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False))
op.add_column('call_requests', sa.Column('live_at', sa.DateTime(timezone=True), nullable=True))
# ### end Alembic commands ###

Wyświetl plik

@ -5,7 +5,7 @@ import uuid
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Tuple
from sqlalchemy import func, text
from sqlalchemy import func, or_, text
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.engine import Row
from sqlalchemy.exc import IntegrityError, NoResultFound
@ -413,7 +413,7 @@ def create_request_calls(
request_id=specification.request_id,
parameters=specification.parameters,
expires_at=expires_at,
live_at=datetime.fromtimestamp(live_at),
live_at=datetime.fromtimestamp(live_at) if live_at is not None else None,
)
db_session.add(request)
@ -484,7 +484,10 @@ def list_call_requests(
metatx_requester_id: Optional[uuid.UUID] = None,
) -> List[Row[Tuple[CallRequest, RegisteredContract, CallRequestType]]]:
"""
List call requests for the given moonstream_user_id
List call requests.
Argument moonstream_user_id took from authorization workflow. And if it is specified
then user has access to call_requests before live_at param.
"""
if caller is None:
raise ValueError("caller must be specified")
@ -525,11 +528,11 @@ def list_call_requests(
)
if not show_before_live_at:
query = query.filter(
CallRequest.live_at < func.now(),
or_(CallRequest.live_at < func.now(), CallRequest.live_at == None)
)
else:
query = query.filter(
CallRequest.live_at < func.now(),
or_(CallRequest.live_at < func.now(), CallRequest.live_at == None)
)
if offset is not None:

Wyświetl plik

@ -307,7 +307,7 @@ class CallRequestResponse(BaseModel):
request_id: str
parameters: Dict[str, Any]
expires_at: Optional[datetime] = None
live_at: datetime
live_at: Optional[datetime] = None
created_at: datetime
updated_at: datetime

Wyświetl plik

@ -316,7 +316,7 @@ class CallRequest(Base):
parameters = Column(JSONB, nullable=False)
expires_at = Column(DateTime(timezone=True), nullable=True, index=True)
live_at = Column(DateTime(timezone=True), server_default=utcnow(), nullable=False)
live_at = Column(DateTime(timezone=True), nullable=True)
created_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False