-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Pagination Support to GET /api/v1/activity-log Endpoint #1197 #1223
base: dev
Are you sure you want to change the base?
Conversation
merge dev to main
Update cd.prod.yaml
Resolve the merge conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement the changes requested
.gitignore
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the repitions??
README.md
Outdated
@@ -45,7 +45,7 @@ GRANT ALL PRIVILEGES ON DATABASE hng_fast_api TO user; | |||
|
|||
**Starting the database** | |||
after cloning the database, dont run | |||
`alembic revision --autogenerate -m 'initial migration'` | |||
`embic revision --autogenerate -m al'initial migration'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this
"""Get paginated activity logs""" | ||
activity_logs = activity_log_service.fetch_all(db=db, page=page, limit=limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just passing the page and page limits doesn't mean it's reflected in the implementation.
.env.sample
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this deleted, revert it
Description
The current
GET /api/v1/activity-logs
endpoint 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:
GET
request to/api/v1/activity-logs
without any parameters.Custom Pagination:
Send a
GET
request 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:
Acceptance Criteria
page
andlimit
query parameters.page
,limit
,total_items
, andtotal_pages
in the response.