feat: Add Pagination Support to GET /api/v1/activity-log Endpoint #1197#1223
Open
Dafinci01 wants to merge 15 commits intohngprojects:devfrom
Open
feat: Add Pagination Support to GET /api/v1/activity-log Endpoint #1197#1223Dafinci01 wants to merge 15 commits intohngprojects:devfrom
Dafinci01 wants to merge 15 commits intohngprojects:devfrom
Conversation
merge dev to main
Update cd.prod.yaml
|
Resolve the merge conflict |
phurhard
requested changes
Mar 2, 2025
.gitignore
Outdated
Comment on lines
177
to
207
| # Ignore environment files | ||
| .env | ||
| .env.* | ||
| .ven | ||
| .venv | ||
| env | ||
| alembic/env.py | ||
|
|
||
| # Ignore environment and virtual environment files | ||
| .env | ||
| .env.* | ||
| .ven | ||
| .venv | ||
| env | ||
| alembic/env.py | ||
|
|
||
| # Ignore environment and virtual environment files | ||
| .env | ||
| .env.* | ||
| .ven | ||
| .venv | ||
| env | ||
| alembic/env.py | ||
|
|
||
| # Ignore environment and virtual environment files | ||
| .env | ||
| .env.* | ||
| .ven | ||
| .venv | ||
| env | ||
| alembic/env.py |
README.md
Outdated
| **Starting the database** | ||
| after cloning the database, dont run | ||
| `alembic revision --autogenerate -m 'initial migration'` | ||
| `embic revision --autogenerate -m al'initial migration'` |
Comment on lines
+42
to
+43
| """Get paginated activity logs""" | ||
| activity_logs = activity_log_service.fetch_all(db=db, page=page, limit=limit) |
There was a problem hiding this comment.
just passing the page and page limits doesn't mean it's reflected in the implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The current
GET /api/v1/activity-logsendpoint returns all activity logs in a single response, which can lead to performance issues and overly large payloads as the number of logs grows. This enhancement introduces pagination support, allowing clients to fetch logs in manageable chunks.Related Issue (Link to issue ticket)
[Issue #1115](#1115)
Motivation and Context
How Has This Been Tested?
Manual API Testing
Default Pagination:
Sent a GET request to /api/v1/activity-logs without any parameters.
Verified that the response included 20 logs (if available) and the correct pagination metadata.
Custom Pagination:
Sent a GET request to /api/v1/activity-logs?page=2&limit=10.
Confirmed that the response included the correct subset of logs corresponding to page 2 and limit 10, along with accurate pagination metadata.
Edge Case Testing:
Tested scenarios such as negative page values, excessively high limits, and requests for pages beyond the available data.
Verified that appropriate validation errors or empty results were returned.
Testing Steps
Default Pagination:
GETrequest to/api/v1/activity-logswithout any parameters.Custom Pagination:
Send a
GETrequest to/api/v1/activity-logs?page=2&limit=10.Confirm that the response includes the correct subset of logs corresponding to page 2 and limit 10, along with accurate pagination metadata.
Screenshots (if appropriate - Postman, etc):
Types of Changes
Checklist
Proposed Solution
The endpoint should support pagination with the following changes:
Query Parameters:
page(optional, default: 1) - Specifies the page number.limit(optional, default: 20) - Specifies the number of logs per page.Response Structure:
The response should include a pagination object containing:
page: The current page number.limit: The number of logs per page.total_items: The total number of activity logs.total_pages: The total number of pages based on the limit.Default Behavior:
Expected JSON Response Format:
{ "status": "success", "status_code": 200, "message": "Activity logs retrieved successfully", "data": { "logs": [ /* array of activity logs */ ], "pagination": { "page": 1, "limit": 20, "total_items": 100, "total_pages": 5 } } }Acceptance Criteria
pageandlimitquery parameters.page,limit,total_items, andtotal_pagesin the response.