diff --git a/src/app/api/job-posting/siteRequestUtils.js b/src/app/api/job-posting/siteRequestUtils.js index c6976e4..67e8828 100644 --- a/src/app/api/job-posting/siteRequestUtils.js +++ b/src/app/api/job-posting/siteRequestUtils.js @@ -120,19 +120,22 @@ export async function fetchJobPostings( let query = Posting.find({ ...siteCriteria, ...filterObject }); - // Check if sortCriteria is defined before sorting + // Check if sortCriteria is defined and sort by it, ensuring to include _id for uniqueness if (sortCriteria && sortCriteria.datePosted !== undefined) { + // Ensure sortCriteria includes _id to maintain unique ordering + sortCriteria._id = 1; query = query.sort(sortCriteria); + } else { + // Default sort by _id if no sortCriteria is provided + query = query.sort({ _id: 1 }); } - query = query.skip(skip); - - const documents = await query.exec(); - // Split the process and used slice instead of chaining with .limit() to avoid sorted order bug - // Todo: Investigate the bug and fix it - const paginatedDocuments = documents.slice(0, pageSize); + // Apply skip and limit for pagination + query = query.skip(skip).limit(pageSize); - return paginatedDocuments; + // Execute the query and return the results + const documents = await query.exec(); + return documents; } // Function to check if the requested field exists in the schema diff --git a/src/components/jobsite/Footer.jsx b/src/components/jobsite/Footer.jsx index 2216e52..8ee9e29 100644 --- a/src/components/jobsite/Footer.jsx +++ b/src/components/jobsite/Footer.jsx @@ -1,11 +1,12 @@ export default function Footer() { + //Todo: Add the Business name to the coptyright return (