Skip to content

Commit

Permalink
Merge pull request #33 from cheesestringer/feature/nz
Browse files Browse the repository at this point in the history
Fix job search for New Zealand
  • Loading branch information
cheesestringer authored Dec 30, 2024
2 parents dc88cb7 + 84de5e6 commit 8276b0c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "salary-seeker",
"displayName": "Salary Seeker",
"version": "2.0.3",
"version": "2.0.4",
"description": "Take the guess work out of job hunting.",
"author": "cheesestringer",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ export const seeking = 'Seeking...';
export const oneDayInMs = 86_400_000;

export const maxRequests = 12;

export const seekNewZealand = 'seek.co.nz';
export const newZealandQuerySiteKey = 'NZ-Main';
export const newZealandQueryWhere = 'All New Zealand';
16 changes: 11 additions & 5 deletions src/services/seekService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { buggerAllChange, getMiddle, isDevelopment, roundDown, roundUp } from '~common';
import { maxRequests } from '~constants';
import { maxRequests, newZealandQuerySiteKey, newZealandQueryWhere, seekNewZealand } from '~constants';

const searchUrl = `${window.location.origin}/api/jobsearch/v5/search`;

Expand Down Expand Up @@ -32,6 +32,11 @@ const getJobDetails = async (jobId: string) => {
url.searchParams.set('jobid', jobId);
url.searchParams.set('source', 'salary-seeker');

if (url.hostname.toLocaleLowerCase().includes(seekNewZealand)) {
url.searchParams.set('siteKey', newZealandQuerySiteKey);
url.searchParams.set('where', newZealandQueryWhere);
}

const response = await fetch(url.href);
return response.json();
};
Expand All @@ -47,8 +52,8 @@ const getJobId = (href: string) => {
}
};

export const getPrice = async (url: string, signal: AbortSignal): Promise<readonly [number, number]> => {
const jobId = getJobId(url);
export const getPrice = async (href: string, signal: AbortSignal): Promise<readonly [number, number]> => {
const jobId = getJobId(href);
if (!jobId) {
return null;
}
Expand All @@ -70,8 +75,9 @@ export const getPrice = async (url: string, signal: AbortSignal): Promise<readon
params.set('keywords', job.title);
}

if (url.includes('seek.co.nz')) {
params.set('where', 'New+Zealand');
if (href.toLocaleLowerCase().includes(seekNewZealand)) {
params.set('siteKey', newZealandQuerySiteKey);
params.set('where', newZealandQueryWhere);
}

const maxSalary = await getMaxSalary(jobId, minRange, maxRange, params, signal);
Expand Down

0 comments on commit 8276b0c

Please sign in to comment.