Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ async function getProviderIngestionStatus (req, res, repository, providerId) {
// Is it a problem if our observability API does not tell the provider address?
ingestionStatus: walkerState.status,
lastHeadWalkedFrom: walkerState.lastHead ?? walkerState.head,
adsMissingPieceCID: walkerState.adsMissingPieceCID ?? 0,
entriesNotRetrievable: walkerState.entriesNotRetrievable ?? 0,
piecesIndexed: await repository.countPiecesIndexed(providerId)
})
}
Expand Down
31 changes: 31 additions & 0 deletions api/test/handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ describe('HTTP request handler', () => {
// providerAddress: "state.providerAddress",
ingestionStatus: 'walking',
lastHeadWalkedFrom: 'last-head',
adsMissingPieceCID: 0,
entriesNotRetrievable: 0,
piecesIndexed: 1
})

Expand Down Expand Up @@ -167,6 +169,8 @@ describe('HTTP request handler', () => {
providerId: 'provider-id',
ingestionStatus: 'walking',
lastHeadWalkedFrom: 'head',
adsMissingPieceCID: 0,
entriesNotRetrievable: 0,
piecesIndexed: 1
})

Expand All @@ -175,5 +179,32 @@ describe('HTTP request handler', () => {
`public, max-age=${60}`
)
})

it('returns the number of adsMissingPieceCID and entriesNotRetrievable', async () => {
await repository.setWalkerState('provider-id', {
status: 'walking',
head: 'head',
entriesNotRetrievable: 10,
adsMissingPieceCID: 20
})

const res = await fetch(new URL('/ingestion-status/provider-id', baseUrl))
await assertResponseStatus(res, 200)
const body = await res.json()

assert.deepStrictEqual(body, {
providerId: 'provider-id',
ingestionStatus: 'walking',
lastHeadWalkedFrom: 'head',
entriesNotRetrievable: 10,
adsMissingPieceCID: 20,
piecesIndexed: 0
})

assert.strictEqual(
res.headers.get('cache-control'),
`public, max-age=${60}`
)
})
})
})