Skip to content

Commit

Permalink
Fix failures to find most recently added version index object
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredgalanis committed Jul 15, 2020
1 parent 67d0d14 commit 8edfa5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ async function processDocs(driver, project) {

await driver.write(
'versions',
[{ id: project, name: project, versions }],
[{
id: project,
name: project,
index_date_timestamp: Date.now(),
versions
}],
project
)
} catch (err) {
Expand Down
6 changes: 5 additions & 1 deletion lib/drivers/algolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ async function getPreviouslyIndexedVersions(projectName) {
return []
}

let hit = hits.find(hit => hit.name === projectName)
let hit = hits.filter(hit => (hit.name === projectName) && hit.index_date_timestamp)
.sort(function (a, b) {
return a.index_date_timestamp - b.index_date_timestamp;
})
.pop()

if (!hit) {
return []
Expand Down

0 comments on commit 8edfa5b

Please sign in to comment.