Skip to content

Commit

Permalink
fix: add sort to endpoints limitted to 1k records which are now missi…
Browse files Browse the repository at this point in the history
…ng data
  • Loading branch information
robcxyz committed Mar 19, 2024
1 parent 6abafbb commit 714a2b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions balanced_backend/api/v1/endpoints/contract_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ async def contract_methods(
) -> Union[List[DailyHistorical], Response]:
"""Return list of contract methods over time."""

query = select(DailyHistorical).offset(skip).limit(limit).order_by(DailyHistorical.timestamp)
query = select(DailyHistorical).offset(skip).limit(limit).order_by(
DailyHistorical.timestamp.desc()
)

if address is not None:
query = query.where(DailyHistorical.address == address)
Expand Down Expand Up @@ -84,7 +86,9 @@ async def historical(
start_timestamp: int = None,
end_timestamp: int = None,
) -> Union[List[DailyHistorical], Response]:
query = select(DailyHistorical).offset(skip).limit(limit).order_by(DailyHistorical.timestamp)
query = select(DailyHistorical).offset(skip).limit(limit).order_by(
DailyHistorical.timestamp.desc()
)

if address is not None:
query = query.where(DailyHistorical.address == address)
Expand Down
8 changes: 6 additions & 2 deletions balanced_backend/api/v1/endpoints/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ async def contract_volumes(
) -> Union[List[ContractMethodVolume], Response]:
"""Return list of delegations."""

query = select(ContractMethodVolume).offset(skip).limit(limit)
query = select(ContractMethodVolume).offset(skip).limit(limit).order_by(
ContractMethodVolume.end_timestamp.desc()
)

if address is not None:
query = query.where(ContractMethodVolume.address == address)
Expand Down Expand Up @@ -96,7 +98,9 @@ async def contract_volumes(
) -> Union[List[ContractMethodVolume], Response]:
"""Return list of delegations."""

query = select(ContractMethodVolume).offset(skip).limit(limit)
query = select(ContractMethodVolume).offset(skip).limit(limit).order_by(
ContractMethodVolume.end_timestamp.desc()
)

if address is not None:
query = query.where(ContractMethodVolume.address == address)
Expand Down

0 comments on commit 714a2b5

Please sign in to comment.