mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #4126 from omnivore-app/fix/digest-score-client-fallback
fix: returns a stub score (0) for "each item" in case score api throws an error
This commit is contained in:
commit
b3c2e34c10
2 changed files with 5 additions and 4 deletions
|
|
@ -248,7 +248,7 @@ const rankCandidates = async (
|
|||
const scores = await scoreClient.getScores(data)
|
||||
// update scores for candidates
|
||||
candidates.forEach((item) => {
|
||||
item.score = scores[item.id].score || 0
|
||||
item.score = scores[item.id]?.score || 0
|
||||
})
|
||||
|
||||
// rank candidates by score in descending order
|
||||
|
|
|
|||
|
|
@ -90,9 +90,10 @@ class ScoreClientImpl implements ScoreClient {
|
|||
logError(error)
|
||||
|
||||
// Returns a stub score (0) in case of an error
|
||||
return {
|
||||
[Object.keys(data.items)[0]]: { score: 0 },
|
||||
}
|
||||
return Object.keys(data.items).reduce((acc, itemId) => {
|
||||
acc[itemId] = { score: 0 }
|
||||
return acc
|
||||
}, {} as ScoreApiResponse)
|
||||
} finally {
|
||||
const duration = (Date.now() - start) / 1000 // in seconds
|
||||
latency.observe(duration)
|
||||
|
|
|
|||
Loading…
Reference in a new issue