Skip to content

Commit

Permalink
summarize current and out-of-date indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Nov 21, 2023
1 parent 14a5399 commit 3bea378
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/unit/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def test_catalog():
res = client.get("/catalog")
assert res.status_code == 200, res
data = res.json()
assert "current" in data
assert "eu_fsf" in data["current"]
assert "datasets" in data
datasets = {d["name"]: d for d in data["datasets"]}
assert datasets["us_ofac_sdn"]["index_current"] is False
Expand Down
2 changes: 2 additions & 0 deletions yente/data/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class DatasetModel(BaseModel):

class DataCatalogModel(BaseModel):
datasets: List[DatasetModel]
current: List[str]
outdated: List[str]


class Algorithm(BaseModel):
Expand Down
10 changes: 9 additions & 1 deletion yente/routers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ async def catalog() -> DataCatalogModel:
"""
catalog = await get_catalog()
await sync_dataset_versions(catalog)
return DataCatalogModel.model_validate(catalog.to_dict())
response = catalog.to_dict()
response["current"] = []
response["outdated"] = []
for dataset in catalog.datasets:
if dataset.load and dataset.index_version == dataset.version:
response["current"].append(dataset.name)
elif dataset.index_version is not None:
response["outdated"].append(dataset.name)
return DataCatalogModel.model_validate(response)


@router.get(
Expand Down

0 comments on commit 3bea378

Please sign in to comment.