feat: add support for indicating workplaceTypes (#296)
This commit is contained in:
@@ -32,6 +32,9 @@ export const manifest: ExtractorManifest = {
|
||||
? parseInt(context.settings.jobspyResultsWanted, 10)
|
||||
: undefined,
|
||||
countryIndeed: context.settings.jobspyCountryIndeed,
|
||||
workplaceTypes: context.settings.workplaceTypes
|
||||
? JSON.parse(context.settings.workplaceTypes)
|
||||
: undefined,
|
||||
onProgress: (event) => {
|
||||
if (context.shouldCancel?.()) return;
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ export interface RunJobSpyOptions {
|
||||
searchTerms?: string[];
|
||||
location?: string;
|
||||
locations?: string[];
|
||||
workplaceTypes?: Array<"remote" | "hybrid" | "onsite">;
|
||||
resultsWanted?: number;
|
||||
hoursOld?: number;
|
||||
countryIndeed?: string;
|
||||
@@ -142,6 +143,14 @@ export interface JobSpyResult {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function deriveIsRemoteFlag(
|
||||
workplaceTypes: Array<"remote" | "hybrid" | "onsite"> | undefined,
|
||||
): boolean | undefined {
|
||||
return workplaceTypes?.length === 1 && workplaceTypes[0] === "remote"
|
||||
? true
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export async function runJobSpy(
|
||||
options: RunJobSpyOptions = {},
|
||||
): Promise<JobSpyResult> {
|
||||
@@ -224,7 +233,10 @@ export async function runJobSpy(
|
||||
"1",
|
||||
),
|
||||
JOBSPY_IS_REMOTE: String(
|
||||
options.isRemote ?? process.env.JOBSPY_IS_REMOTE ?? "0",
|
||||
options.isRemote ??
|
||||
deriveIsRemoteFlag(options.workplaceTypes) ??
|
||||
process.env.JOBSPY_IS_REMOTE ??
|
||||
"0",
|
||||
),
|
||||
JOBSPY_OUTPUT_CSV: outputCsv,
|
||||
JOBSPY_OUTPUT_JSON: outputJson,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseJobSpyProgressLine } from "../src/run";
|
||||
import { deriveIsRemoteFlag, parseJobSpyProgressLine } from "../src/run";
|
||||
|
||||
describe("parseJobSpyProgressLine", () => {
|
||||
it("parses term_start progress lines", () => {
|
||||
@@ -37,4 +37,15 @@ describe("parseJobSpyProgressLine", () => {
|
||||
it("returns null for non-progress lines", () => {
|
||||
expect(parseJobSpyProgressLine("Found 20 jobs")).toBeNull();
|
||||
});
|
||||
|
||||
it("maps remote-only workplace types to isRemote", () => {
|
||||
expect(deriveIsRemoteFlag(["remote"])).toBe(true);
|
||||
});
|
||||
|
||||
it("does not force JobSpy remote filtering for hybrid or onsite selections", () => {
|
||||
expect(deriveIsRemoteFlag(["hybrid"])).toBeUndefined();
|
||||
expect(deriveIsRemoteFlag(["onsite"])).toBeUndefined();
|
||||
expect(deriveIsRemoteFlag(["remote", "hybrid"])).toBeUndefined();
|
||||
expect(deriveIsRemoteFlag(["remote", "hybrid", "onsite"])).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user