mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Parse the single score from the digest-score service
This commit is contained in:
parent
e4bc3c72fa
commit
7466501c95
3 changed files with 7 additions and 3 deletions
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue