diff --git a/engineapi/engineapi/contracts_actions.py b/engineapi/engineapi/contracts_actions.py index 4d9f6ca8..ceed9a13 100644 --- a/engineapi/engineapi/contracts_actions.py +++ b/engineapi/engineapi/contracts_actions.py @@ -481,7 +481,7 @@ def list_call_requests( limit: int = 10, offset: Optional[int] = None, show_expired: bool = False, - show_before_live_at: bool = False, + live_after: Optional[int] = None, metatx_requester_id: Optional[uuid.UUID] = None, ) -> List[Row[Tuple[CallRequest, RegisteredContract, CallRequestType]]]: """ @@ -527,15 +527,17 @@ def list_call_requests( query = query.filter( CallRequest.metatx_requester_id == metatx_requester_id, ) - if not show_before_live_at: - query = query.filter( - or_(CallRequest.live_at < func.now(), CallRequest.live_at == None) - ) else: query = query.filter( or_(CallRequest.live_at < func.now(), CallRequest.live_at == None) ) + if live_after is not None: + assert live_after == int(live_after) + if live_after <= 0: + raise ValueError("live_after must be positive") + query = query.filter(CallRequest.live_at >= datetime.fromtimestamp(live_after)) + if offset is not None: query = query.offset(offset) diff --git a/engineapi/engineapi/routes/metatx.py b/engineapi/engineapi/routes/metatx.py index 092540b7..23a14b26 100644 --- a/engineapi/engineapi/routes/metatx.py +++ b/engineapi/engineapi/routes/metatx.py @@ -285,7 +285,7 @@ async def list_requests_route( limit: int = Query(100), offset: Optional[int] = Query(None), show_expired: bool = Query(False), - show_before_live_at: bool = Query(False), + live_after: Optional[int] = Query(None), user: Optional[BugoutUser] = Depends(request_none_or_user_auth), db_session: Session = Depends(db.yield_db_read_only_session), ) -> List[data.CallRequestResponse]: @@ -303,7 +303,7 @@ async def list_requests_route( limit=limit, offset=offset, show_expired=show_expired, - show_before_live_at=show_before_live_at, + live_after=live_after, metatx_requester_id=user.id if user is not None else None, ) except ValueError as e: