From 7b675906d7012f49863c8ec0b42b0c60baefc8dd Mon Sep 17 00:00:00 2001 From: oliverhuangcode Date: Mon, 27 Apr 2026 22:08:05 +1000 Subject: [PATCH 1/2] Update sponsor algorithm --- frontend/next-env.d.ts | 2 +- frontend/src/actions/jobs.fetch.ts | 38 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/frontend/next-env.d.ts b/frontend/next-env.d.ts index 9edff1c..c4b7818 100644 --- a/frontend/next-env.d.ts +++ b/frontend/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -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. diff --git a/frontend/src/actions/jobs.fetch.ts b/frontend/src/actions/jobs.fetch.ts index 7ac1f23..2413881 100644 --- a/frontend/src/actions/jobs.fetch.ts +++ b/frontend/src/actions/jobs.fetch.ts @@ -136,18 +136,32 @@ async function withDbConnection( } } +const SPONSOR_TIERS: Record = { + // 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, minSponsors: number = -1, - prioritySponsors: Array = ["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); @@ -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"); @@ -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 })); From 7eff07df2a34c910e308bc7ca8765f76f93ca62d Mon Sep 17 00:00:00 2001 From: oliverhuangcode Date: Tue, 28 Apr 2026 20:34:11 +1000 Subject: [PATCH 2/2] Fix pagination siblings --- frontend/src/components/jobs/job-pagination.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/jobs/job-pagination.tsx b/frontend/src/components/jobs/job-pagination.tsx index 8950489..59b239f 100644 --- a/frontend/src/components/jobs/job-pagination.tsx +++ b/frontend/src/components/jobs/job-pagination.tsx @@ -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) => ({