Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions frontend/src/app/jobs/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ export async function getJobs(

if (minSponsors == 0) {
const [jobs, total] = await Promise.all([
collection.find(query).skip(skip).limit(PAGE_SIZE).toArray(),
collection
.find(query)
.sort({ created_at: -1 })
.skip(skip)
.limit(PAGE_SIZE)
.toArray(),
collection.countDocuments(query),
]);
return {
Expand Down Expand Up @@ -151,12 +156,13 @@ export async function getJobs(
const [otherJobs, total] = await Promise.all([
collection
.find(filteredQuery)
.sort({ created_at: -1 })
.skip(skip)
.limit(PAGE_SIZE - sponsoredJobs.length)
.toArray(),
collection.countDocuments(query), // Total should still include all jobs matching the original query
]);
// Merge jobs and make sure we dont exceed PAGE_SIZE also add highlight property
// Merge jobs and make sure we don't exceed PAGE_SIZE also add highlight property
const mergedJobs = [
...sponsoredJobs.map((job) => ({ ...job, highlight: true })),
...otherJobs.map((job) => ({ ...job, highlight: false })),
Expand Down