Skip to content

Commit

Permalink
fix: page_size param for projects endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Sep 6, 2023
1 parent 7f8649f commit 1db198c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v1.0.1 (2023-09-05)

- Fixes a bug where `page_size` for the `/projects` endpoint wasn't respected

## v1.0.0 (2023-09-01)

- Drops support for Python 3.7
Expand Down
2 changes: 1 addition & 1 deletion harvey/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.0.1'
9 changes: 5 additions & 4 deletions harvey/repos/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def retrieve_projects(request: flask.Request) -> Dict[str, List[Any]]:
"""Retrieve a list of projects stored in Harvey by scanning the `projects` directory."""
projects: Dict[str, Any] = {'projects': []}
total_projects = 0
project_owners = os.listdir(Config.projects_path)
page_size = get_page_size(request)

Expand All @@ -25,11 +26,11 @@ def retrieve_projects(request: flask.Request) -> Dict[str, List[Any]]:
project_names.remove('.DS_Store')
for project_name in project_names:
final_project_name = f'{project_owner}-{project_name}'
projects['projects'].append(final_project_name)
total_projects += 1

if len(projects['projects']) > page_size:
break
if len(projects['projects']) < page_size:
projects['projects'].append(final_project_name)

projects['total_count'] = len(projects['projects'])
projects['total_count'] = total_projects

return projects

0 comments on commit 1db198c

Please sign in to comment.