Skip to content

Commit

Permalink
Add pagination to association-table endpoint (#204)
Browse files Browse the repository at this point in the history
Fixes #197
  • Loading branch information
kevinschaper authored Jul 12, 2023
1 parent 2371aab commit 700b9bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ help:
@echo "│ test-frontend Run frontend tests │"
@echo "│ │"
@echo "│ dev-frontend Run frontend in development mode │"
@echo "│ dev-backend Run backend in development mode │"
@echo "│ dev-api Run api in development mode "
@echo "│ │"
@echo "│ docker-build Build docker image │"
@echo "│ docker-push Push docker image │"
Expand Down
12 changes: 10 additions & 2 deletions backend/src/monarch_py/api/entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fastapi import APIRouter, HTTPException, Query
from fastapi import APIRouter, Depends, HTTPException, Query
from monarch_py.api.additional_models import PaginationParams
from monarch_py.api.config import settings
from monarch_py.datamodels.model import AssociationTableResults, Node
from monarch_py.implementations.solr.solr_implementation import SolrImplementation
Expand Down Expand Up @@ -49,6 +50,7 @@ def _association_table(
title="Type of association to retrieve association table data for",
),
query: str = Query(None, example="thumb", title="Query string to limit results to a subset"),
pagination: PaginationParams = Depends(),
) -> AssociationTableResults:
"""
Retrieves association table data for a given entity and association type
Expand All @@ -61,6 +63,12 @@ def _association_table(
AssociationResults: Association table data for the specified entity and association type
"""
solr = SolrImplementation(base_url=settings.solr_url)
response = solr.get_association_table(entity=id, category=category, q=query)
response = solr.get_association_table(
entity=id,
category=category,
q=query,
offset=pagination.offset,
limit=pagination.limit
)

return response

0 comments on commit 700b9bc

Please sign in to comment.