Skip to content

Commit fa18997

Browse files
committed
fixing some rendering issues in map
1 parent d43c5b3 commit fa18997

File tree

7 files changed

+1140
-1491
lines changed

7 files changed

+1140
-1491
lines changed

lib/api/routes/listingsRouter.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ listingsRouter.get('/table', async (req, res) => {
6464
});
6565

6666
listingsRouter.get('/map', async (req, res) => {
67-
const { jobId, minPrice, maxPrice } = req.query || {};
67+
const { jobId } = req.query || {};
6868

6969
res.body = listingStorage.getListingsForMap({
7070
jobId: nullOrEmpty(jobId) ? null : jobId,
71-
minPrice: minPrice ? parseInt(minPrice, 10) : null,
72-
maxPrice: maxPrice ? parseInt(maxPrice, 10) : null,
7371
userId: req.session.currentUser,
7472
isAdmin: isAdminFn(req),
7573
});

lib/services/storage/listingsStorage.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,11 @@ export const updateListingGeocoordinates = (id, latitude, longitude) => {
432432
*
433433
* @param {Object} params
434434
* @param {string} [params.jobId]
435-
* @param {boolean} [params.activeOnly=true]
436-
* @param {number} [params.minPrice]
437-
* @param {number} [params.maxPrice]
438435
* @param {string} [params.userId]
439436
* @param {boolean} [params.isAdmin=false]
440437
* @returns {{listings: Object[], maxPrice: number}} Object containing listings and maxPrice.
441438
*/
442-
export const getListingsForMap = ({ jobId, minPrice, maxPrice, userId = null, isAdmin = false } = {}) => {
439+
export const getListingsForMap = ({ jobId, userId = null, isAdmin = false } = {}) => {
443440
const baseWhereParts = [
444441
'l.latitude IS NOT NULL',
445442
'l.longitude IS NOT NULL',
@@ -461,15 +458,6 @@ export const getListingsForMap = ({ jobId, minPrice, maxPrice, userId = null, is
461458
}
462459

463460
const wherePartsForListings = [...baseWhereParts];
464-
if (minPrice !== undefined && minPrice !== null) {
465-
params.minPrice = minPrice;
466-
wherePartsForListings.push('l.price >= @minPrice');
467-
}
468-
469-
if (maxPrice !== undefined && maxPrice !== null) {
470-
params.maxPrice = maxPrice;
471-
wherePartsForListings.push('l.price <= @maxPrice');
472-
}
473461

474462
const listings = SqliteConnection.query(
475463
`SELECT l.*, j.name AS job_name
@@ -479,17 +467,8 @@ export const getListingsForMap = ({ jobId, minPrice, maxPrice, userId = null, is
479467
params,
480468
);
481469

482-
const maxPriceRow = SqliteConnection.query(
483-
`SELECT MAX(l.price) AS maxPrice
484-
FROM listings l
485-
LEFT JOIN jobs j ON j.id = l.job_id
486-
WHERE ${baseWhereParts.join(' AND ')}`,
487-
params,
488-
)[0];
489-
490470
return {
491471
listings,
492-
maxPrice: maxPriceRow?.maxPrice || 0,
493472
};
494473
};
495474

0 commit comments

Comments
 (0)