Skip to content

Commit

Permalink
feat: get activity by warehouseUnitId working
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Oct 9, 2024
1 parent f270468 commit da92a0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/api/v1/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def get_activity_by_cw_unit_id(
(activities, total) = db_crud.select_activity_with_pagination(
model=models.Activity,
filters=activity_filters,
order_by='desc',
order_by=[models.Activity.height.asc()],
page=page,
limit=limit,
)
Expand Down
12 changes: 10 additions & 2 deletions app/crud/chia.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ def _get_paginated_data(self, path: str, search_params: Dict[str, Any]) -> List[
# to prevent an infinite loop need to assume that there is no data matching the search from this iteration on
return all_data

all_data.extend(data["data"]) # Add data from the current page
try:
if data["page"] and data["pageCount"] and data["data"]:
all_data.extend(data["data"]) # Add data from the current page
else:
all_data.append(data) # data was not paginated, append and return
return all_data
except:
all_data.append(data) # data was not paginated, append and return
return all_data

if page >= data["pageCount"]:
break # Exit loop if all pages have been processed
Expand Down Expand Up @@ -183,7 +191,7 @@ def combine_climate_units_and_metadata(self, search: Dict[str, Any]) -> List[Dic
warehouse_project_id = unit["issuance"]["warehouseProjectId"]
project = project_by_id[warehouse_project_id]
except (KeyError, TypeError):
logger.warning(f"Can not get project by warehouse_project_id: {warehouse_project_id}")
logger.warning(f"Can not get project by warehouse_project_id")
continue

org_metadata = metadata_by_id.get(unit_org_uid)
Expand Down

0 comments on commit da92a0f

Please sign in to comment.