-
-
Notifications
You must be signed in to change notification settings - Fork 64
Pagination for home page and category page #158
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This draft PR implements pagination for both the home and category pages. Key changes include:
- Addition of a new API endpoint (returnHomeFeedData) and a refactored database query function (getHomeFeedData) to support paginated post retrieval.
- Updates to the front-end code (HTML template and JavaScript) for rendering post cards with pagination.
- Removal of redundant database connection code from the index and category routes and registration of new blueprints.
Reviewed Changes
Copilot reviewed 9 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
utils/getHomeFeedData.py | Introduces a new function to fetch home feed data with pagination parameters. |
static/tailwindUI/pureHtmlMacro/postCardMacro.html | Adds an HTML template for post cards used in the home feed. |
static/tailwindUI/js/homeFeed.js | Updates JS logic to fetch and render paginated posts and handle spinner states. |
routes/returnPostAnalyticsData.py | Changes the error response to use make_response for consistency. |
routes/returnHomeFeedData.py | Creates a new endpoint to serve home feed data based on query parameters. |
routes/index.py | Refactors the home route to remove inline database access and instead defers to external data fetching via blueprints. |
routes/category.py | Removes the inline DB query in favor of an alternative approach for handling category posts. |
modules.py | Imports the new getHomeFeedData function. |
app.py | Registers the new blueprint for the home feed data endpoint. |
Files not reviewed (4)
- templates/tailwindUI/category.html.jinja: Language not supported
- templates/tailwindUI/components/sortMenu.html.jinja: Language not supported
- templates/tailwindUI/index.html.jinja: Language not supported
- templates/tailwindUI/user.html.jinja: Language not supported
Comments suppressed due to low confidence (1)
routes/category.py:109
- The fetching of post data has been removed from this route without a clear replacement, leaving the template without the expected 'posts' data. Confirm if this change is intentional.
return render_template(..., category=translations["categories"][category.lower()], ...)
static/tailwindUI/js/homeFeed.js
Outdated
|
||
// Id | ||
let homeSpinner = document.getElementById("homeSpinner") | ||
let loadMoreSpinner = document.getElementById("lodeMoreSpinner") |
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.
The element ID 'lodeMoreSpinner' appears to be a typo. Verify if the intended ID is 'loadMoreSpinner'.
let loadMoreSpinner = document.getElementById("lodeMoreSpinner") | |
let loadMoreSpinner = document.getElementById("loadMoreSpinner") |
Copilot uses AI. Check for mistakes.
|
||
if (connection.ok) { |
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.
The variable 'posts' is assigned without declaration, which could lead to unintended global scope. Consider declaring it with 'let' or 'const'.
if (connection.ok) { | |
let posts; // Declare posts locally |
Copilot uses AI. Check for mistakes.
routes/returnHomeFeedData.py
Outdated
print(category, by, sort, limit, offset, "rohit") | ||
|
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.
Unexpected debug print statement ('rohit') found in production code. It should be removed before deployment.
print(category, by, sort, limit, offset, "rohit") |
Copilot uses AI. Check for mistakes.
Good job. I love that. we can merge it after fixes. Please check copilot report. |
Thanks!, I've fixed those typos and bugs |
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.
Pull Request Overview
This PR implements pagination for the home page and category page and refactors the API endpoints to retrieve paginated post data. Key changes include a new utility function for fetching paginated home feed data, updates to the home feed and category routes to remove direct database calls, and integration of front-end logic with a new HTML macro and JavaScript to render posts.
Reviewed Changes
Copilot reviewed 9 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
utils/getHomeFeedData.py | New utility function to fetch and return paginated home feed data from the database. |
static/tailwindUI/pureHtmlMacro/postCardMacro.html | Added HTML macro for rendering individual post cards. |
static/tailwindUI/js/homeFeed.js | Added JavaScript logic to load, render, and paginate home feed data using the new API. |
routes/returnPostAnalyticsData.py | Updated the analytics endpoint response with make_response. |
routes/returnHomeFeedData.py | Introduced a new API endpoint to serve paginated home feed data. |
routes/index.py | Refactored the home page route to use pagination parameters and remove direct DB calls. |
routes/category.py | Updated category route to integrate pagination and remove direct DB calls. |
modules.py | Imported the new getHomeFeedData utility. |
app.py | Registered the new home feed data blueprint. |
Files not reviewed (4)
- templates/tailwindUI/category.html.jinja: Language not supported
- templates/tailwindUI/components/sortMenu.html.jinja: Language not supported
- templates/tailwindUI/index.html.jinja: Language not supported
- templates/tailwindUI/user.html.jinja: Language not supported
category = request.args.get("category", type=str, default="all") | ||
by = request.args.get("by", type=str, default="hot") | ||
sort = request.args.get("sort", type=str, default="desc") | ||
limit = request.args.get("limit", type=int, default="4") |
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.
The default value for 'limit' is set as a string instead of an integer; change it to default=4 to ensure correct type conversion.
limit = request.args.get("limit", type=int, default="4") | |
limit = request.args.get("limit", type=int, default=4) |
Copilot uses AI. Check for mistakes.
const tempContainer = document.createElement('div'); | ||
tempContainer.innerHTML = postCardHtml; | ||
|
||
// Register macro in dome |
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.
Typo in comment: 'dome' should be corrected to 'DOM'.
// Register macro in dome | |
// Register macro in DOM |
Copilot uses AI. Check for mistakes.
Fixes #
Proposed Changes