Skip to content

Commit

Permalink
make helper fct in ResultsFactory and update enum comment
Browse files Browse the repository at this point in the history
  • Loading branch information
alapre committed Aug 14, 2024
1 parent e042f77 commit 7317f4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/models/searchservice/response/Source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export enum Source {
Custom = 'CUSTOM_SEARCHER',
/** The result is from a document vertical. */
DocumentVertical = 'DOCUMENT_VERTICAL',
/** The result is from a document vertical. */
/** The result is from a function vertical. */
FunctionVertical = 'FUNCTION_VERTICAL',
}
23 changes: 9 additions & 14 deletions src/transformers/searchservice/ResultsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,18 @@ export class ResultsFactory {
}

private static fromCustomSource(result: any, index: number): Result {
return this.fromCustomSourceHelper(result, index, Source.Custom);
}

private static fromFunctionVertical(result: any, index: number): Result {
return this.fromCustomSourceHelper(result, index, Source.FunctionVertical);
}

private static fromCustomSourceHelper(result: any, index: number, source: Source): Result {
const rawData = result.data ?? result;
return {
rawData: rawData,
source: Source.Custom,
source: source,
index: index,
name: rawData.name,
description: rawData.description, // Do we want to truncate this like in the SDK?
Expand All @@ -139,17 +147,4 @@ export class ResultsFactory {
entityType: result.type,
};
}

public static fromFunctionVertical(result: any, index: number): Result {
const rawData = result.data ?? result;
return {
rawData: rawData,
source: Source.FunctionVertical,
index: index,
name: rawData.name,
description: rawData.description,
link: rawData.website,
id: rawData.id,
};
}
}

0 comments on commit 7317f4e

Please sign in to comment.