🔧 Fixes
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
throttleAdapterEnhancer,
|
||||
} from "axios-extensions";
|
||||
import { matchScorer, rankVolumes } from "../utils/searchmatchscorer.utils";
|
||||
import { isNil } from "lodash";
|
||||
|
||||
const CV_BASE_URL = "https://comicvine.gamespot.com/api/";
|
||||
console.log("KEYYYYYYYY", process.env.COMICVINE_API_KEY);
|
||||
@@ -157,6 +158,7 @@ export default class ComicVineService extends Service {
|
||||
searchParams: {
|
||||
searchTerms: {
|
||||
name: string;
|
||||
subtitle?: string;
|
||||
number: string;
|
||||
year: string;
|
||||
};
|
||||
@@ -165,7 +167,9 @@ export default class ComicVineService extends Service {
|
||||
rawFileDetails: object;
|
||||
}>
|
||||
) => {
|
||||
console.log("scorer", ctx.params.scorerConfiguration);
|
||||
const results: any = [];
|
||||
let subtitleFilter = "";
|
||||
const volumes = await this.fetchVolumesFromCV(
|
||||
ctx.params,
|
||||
results,
|
||||
@@ -182,8 +186,11 @@ export default class ComicVineService extends Service {
|
||||
}
|
||||
volumeIdString += `${volumeId}|`;
|
||||
});
|
||||
const issueYear = parseInt(ctx.params.scorerConfiguration.searchParams.searchTerms.year, 10);
|
||||
if(!isNil(ctx.params.scorerConfiguration.searchParams.searchTerms.subtitle)) {
|
||||
subtitleFilter = `name:${ctx.params.scorerConfiguration.searchParams.searchTerms.subtitle}`;
|
||||
}
|
||||
// 2b. cover_date:2014-01-01|2016-12-31 for the issue year 2015
|
||||
const issueYear = parseInt(ctx.params.scorerConfiguration.searchParams.searchTerms.year, 10);
|
||||
const coverDateFilter = `cover_date:${issueYear - 1}-01-01|${issueYear + 1}-12-31`;
|
||||
const filterString = `issue_number:${ctx.params.scorerConfiguration.searchParams.searchTerms.number},${volumeIdString},${coverDateFilter}`;
|
||||
console.log(filterString);
|
||||
|
||||
@@ -89,7 +89,6 @@ export const rankVolumes = (volumes: any, scorerConfiguration: any) => {
|
||||
// Iterate over volumes, checking to see:
|
||||
// 1. If the detected year of the issue falls in the range (end_year >= {detected year for issue} >= start_year )
|
||||
// 2. If there is a strong string comparison between the volume name and the issue name ??
|
||||
console.log(volumes.length);
|
||||
const issueNumber = parseInt(
|
||||
scorerConfiguration.searchParams.searchTerms.number,
|
||||
10
|
||||
@@ -108,25 +107,35 @@ export const rankVolumes = (volumes: any, scorerConfiguration: any) => {
|
||||
const lastIssueNumber = !isNil(volume.last_issue)
|
||||
? parseInt(volume.last_issue.issue_number, 10)
|
||||
: null;
|
||||
const issueNameMatchScore = stringSimilarity.compareTwoStrings(
|
||||
let issueNameMatchScore = stringSimilarity.compareTwoStrings(
|
||||
scorerConfiguration.searchParams.searchTerms.name,
|
||||
volume.name
|
||||
);
|
||||
// 1. If issue year starts after the candidate volume's start year or is the same year, +2 to volumeMatchScore
|
||||
// 1. If there is a subtitle in the candidate volume's name, add it to the issueNameMatchScore
|
||||
// If not, move on.
|
||||
let subtitleMatchScore = 0;
|
||||
if(!isNil(scorerConfiguration.searchParams.searchTerms.subtitle)) {
|
||||
subtitleMatchScore = stringSimilarity.compareTwoStrings(scorerConfiguration.searchParams.searchTerms.subtitle, volume.name);
|
||||
console.log(scorerConfiguration.searchParams.searchTerms.subtitle, subtitleMatchScore);
|
||||
if(subtitleMatchScore > 0.1) {
|
||||
issueNameMatchScore += subtitleMatchScore;
|
||||
}
|
||||
}
|
||||
// 2. If issue year starts after the candidate volume's start year or is the same year, +2 to volumeMatchScore
|
||||
if (!isNil(volumeStartYear)) {
|
||||
if (isSameYear(issueYear, volumeStartYear) ||
|
||||
isAfter(issueYear, volumeStartYear)) {
|
||||
volumeMatchScore += 2;
|
||||
}
|
||||
}
|
||||
// 2. If issue number falls in the range of candidate volume's first issue # and last issue #, +3 to volumeMatchScore
|
||||
// 3. If issue number falls in the range of candidate volume's first issue # and last issue #, +3 to volumeMatchScore
|
||||
if(!isNil(firstIssueNumber) && !isNil(lastIssueNumber)) {
|
||||
if(firstIssueNumber <= issueNumber || issueNumber <= lastIssueNumber) {
|
||||
volumeMatchScore += 3;
|
||||
}
|
||||
}
|
||||
if(issueNameMatchScore > 0.5 && volumeMatchScore > 2) {
|
||||
console.log("VOLUME SCORE: ", volumeMatchScore);
|
||||
console.log("VOLUME SCORE: ", issueNameMatchScore);
|
||||
return volume.id;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user