Parse the single score from the digest-score service

This commit is contained in:
Jackson Harper 2024-05-29 16:40:44 +08:00
parent e4bc3c72fa
commit 7466501c95
3 changed files with 7 additions and 3 deletions

View file

@ -65,7 +65,7 @@ export const scoreLibraryItem = async (
})
logger.info('Scores', scores)
const score = scores[libraryItem.id]
const score = scores[libraryItem.id]['score']
if (!score) {
logger.error('Failed to score library item', data)
throw new Error('Failed to score library item')

View file

@ -187,7 +187,7 @@ const rankCandidates = async (
const newScores = await getScores(data)
// update scores for candidates
candidates.forEach((item) => {
item.score = newScores[item.id] || 0
item.score = newScores[item.id]['score'] || 0
})
// rank candidates by score in ascending order

View file

@ -20,7 +20,11 @@ export interface ScoreApiRequestBody {
items: Record<string, Feature> // item_id -> feature
}
export type ScoreApiResponse = Record<string, number> // item_id -> score
export type ScoreBody = {
score: number
}
export type ScoreApiResponse = Record<string, ScoreBody> // item_id -> score
export const getScores = async (
data: ScoreApiRequestBody