-
Notifications
You must be signed in to change notification settings - Fork 0
fix: correct utsav pagination offset and include utsavs without packages #285
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,7 @@ import { | |
| } from '../../config/constants.js'; | ||
| import { | ||
| UtsavBooking, | ||
| UtsavDb, | ||
| UtsavPackagesDb | ||
| UtsavDb | ||
| } from '../../models/associations.js'; | ||
| import { userCancelBooking } from '../../helpers/transactions.helper.js'; | ||
| import { openUtsavSeat, sendUtsavBookingUpdateEmail } from '../../helpers/utsavBooking.helper.js'; | ||
|
|
@@ -23,7 +22,7 @@ export const FetchUpcoming = async (req, res) => { | |
|
|
||
| const page = parseInt(req.query.page) || 1; | ||
| const pageSize = parseInt(req.query.page_size) || 10; | ||
| const offset = (page - 1) * (pageSize - 1); | ||
| const offset = (page - 1) * pageSize; | ||
|
|
||
| const utsavs = await database.query( | ||
| ` | ||
|
|
@@ -35,17 +34,17 @@ export const FetchUpcoming = async (req, res) => { | |
| t1.location AS utsav_location, | ||
| t1.status AS utsav_status, | ||
| t1.registration_deadline AS registration_deadline, | ||
| JSON_ARRAYAGG( | ||
| IF(COUNT(t2.id) = 0, JSON_ARRAY(), JSON_ARRAYAGG( | ||
| JSON_OBJECT( | ||
| 'package_id', t2.id, | ||
| 'package_name', t2.name, | ||
| 'package_start', t2.start_date, | ||
| 'package_end', t2.end_date, | ||
| 'package_amount', t2.amount | ||
| ) | ||
| ) AS packages | ||
| )) AS packages | ||
| FROM utsav_db t1 | ||
| JOIN utsav_packages_db t2 ON t1.id = t2.utsavid | ||
| LEFT JOIN utsav_packages_db t2 ON t1.id = t2.utsavid | ||
|
Comment on lines
+37
to
+47
|
||
| WHERE t1.registration_deadline IS NULL OR t1.registration_deadline >= :today | ||
| GROUP BY t1.id | ||
| ORDER BY t1.start_date ASC | ||
|
|
||
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.
Pagination offset math changed here, and
FetchUpcomingnow has new behavior for utsavs with no packages. There are integration tests for other booking controllers undertests/controllers/client/, but none for this controller; adding coverage for non-overlapping page results andpackages: []when no packages exist would help prevent regressions.