time each steps in the update home job

This commit is contained in:
Hongbo Wu 2024-05-29 17:58:28 +08:00
parent 69dbbd7635
commit d1d7f93fc3
2 changed files with 21 additions and 6 deletions

View file

@ -389,8 +389,12 @@ export const updateHome = async (data: UpdateHomeJobData) => {
logger.info(`Updating home for user ${userId}`)
logger.profile('selecting')
const candidates = await selectCandidates(user)
logger.info(`Found ${candidates.length} candidates`)
logger.profile('selecting', {
level: 'info',
message: `Found ${candidates.length} candidates`,
})
if (candidates.length <= 10) {
logger.info('Not enough candidates found')
@ -399,20 +403,32 @@ export const updateHome = async (data: UpdateHomeJobData) => {
// TODO: integrity check on candidates
logger.info('Ranking candidates')
logger.profile('ranking')
const rankedCandidates = await rankCandidates(userId, candidates)
if (rankedCandidates.length === 0) {
logger.info('No candidates found')
return
}
logger.profile('ranking', {
level: 'info',
message: `Ranked ${rankedCandidates.length} candidates`,
})
// TODO: filter candidates
logger.info('Mix home items to create sections')
logger.profile('mixing')
const rankedSections = mixHomeItems(rankedCandidates)
logger.info(`Created ${rankedSections.length} sections`)
logger.profile('mixing', {
level: 'info',
message: `Created ${rankedSections.length} sections`,
})
logger.info('Appending sections to home')
logger.profile('saving')
await appendSectionsToHome(userId, rankedSections, cursor)
logger.profile('saving', {
level: 'info',
message: 'Sections appended to home',
})
logger.info('Home updated for user', { userId })
}

View file

@ -37,7 +37,6 @@ export const getScores = async (
method: 'POST',
headers: {
'Content-Type': 'application/json',
// Authorization: `Bearer ${token}`,
},
body: JSON.stringify(data),
})