Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/dev/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
38 changes: 27 additions & 11 deletions frontend/src/actions/jobs.fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,32 @@ async function withDbConnection<T>(
}
}

const SPONSOR_TIERS: Record<string, number> = {
// Platinum (rank 0) — highest priority
"Jane Street": 0,
Atlassian: 0,
// Gold (rank 1)
"Citadel Securities": 1,
Canva: 1,
"Lyra Technologies": 1,
Susquehanna: 1,
IMC: 1,
Vivcourt: 1,
// Silver (rank 2)
"January Capital": 2,
Optiver: 2,
};

/**
* Fetches paginated and filtered job listings from MongoDB.
*/
export async function getJobs(
filters: Partial<JobFilters>,
minSponsors: number = -1,
prioritySponsors: Array<string> = ["IMC", "Atlassian"],
): Promise<{ jobs: Job[]; total: number }> {
const page = filters.page || 1;
const normalizedFilters = normalizeFiltersForKey(filters);
const priorityStr = prioritySponsors.sort().join(",");
const cacheKey = `jobs:${JSON.stringify(normalizedFilters)}:${page}:${minSponsors}:${priorityStr}`;
const cacheKey = `jobs:${JSON.stringify(normalizedFilters)}:${page}:${minSponsors}`;

// Check cache first
const cached = jobCache.get(cacheKey);
Expand All @@ -156,10 +170,7 @@ export async function getJobs(
return cached as { jobs: Job[]; total: number };
}

logger.info(
{ filters, minSponsors, prioritySponsors },
"Fetching jobs with filters",
);
logger.info({ filters, minSponsors }, "Fetching jobs with filters");

return await withDbConnection(async (client) => {
const collection = client.db("default").collection("active_jobs");
Expand Down Expand Up @@ -196,11 +207,16 @@ export async function getJobs(
])
.toArray();

// Sort by tier (platinum=0 first, gold=1, silver=2, unknown=3),
// shuffling randomly within each tier.
sponsoredJobs = sponsoredJobs
.filter((job) => {
const isPriority = prioritySponsors.includes(job.company.name);
return isPriority ? Math.random() < 0.65 : Math.random() >= 0.35;
})
.map((job) => ({
job,
rank: SPONSOR_TIERS[job.company?.name as string] ?? 3,
rand: Math.random(),
}))
.sort((a, b) => a.rank - b.rank || a.rand - b.rand)
.map(({ job }) => job)
.slice(0, minSponsors)
.map((job) => ({ ...job, highlight: true }));

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/jobs/job-pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function JobPagination({ pageSize = 20 }: JobPaginationProps) {
size="md"
gap={12}
boundaries={1}
siblings={0}
siblings={1}
radius="lg"
color="accent"
getItemProps={(page) => ({
Expand Down
Loading