mirror of
https://github.com/stablyai/orca.git
synced 2026-10-02 08:02:02 +00:00
fix(github): preserve search budget on count fallback
This commit is contained in:
@@ -47,6 +47,9 @@ export async function countWorkItemsForQuery(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (repositoryRateLimitGuard(ownerRepo, 'search', ghOptions).blocked) {
|
||||
return 0
|
||||
}
|
||||
const { stdout } = await ghExecFileAsync(
|
||||
[
|
||||
'api',
|
||||
|
||||
@@ -4,6 +4,25 @@ import { listWorkItems } from './client/list/list-work-items'
|
||||
import { countWorkItems } from './client/list/count-work-items'
|
||||
import metadata from './__fixtures__/work-item-search-metadata.json'
|
||||
|
||||
it('preserves the Search budget floor when the preferred count fails', async () => {
|
||||
api.restSearches = 29
|
||||
api.aliasErrorRepo = 'fixture/repo'
|
||||
|
||||
expect(await countWorkItems('fixture/repo', 'is:issue')).toBe(0)
|
||||
expect(api.calls.some((call) => call.args.includes('graphql'))).toBe(true)
|
||||
expect(api.calls.some((call) => call.args.some((arg) => arg.startsWith('search/issues?')))).toBe(
|
||||
false
|
||||
)
|
||||
expect(api.restSearches).toBe(29)
|
||||
})
|
||||
|
||||
it('still counts through GraphQL when the REST Search budget is below its floor', async () => {
|
||||
api.restSearches = 29
|
||||
|
||||
expect(await countWorkItems('fixture/repo', 'is:issue')).toBe(120)
|
||||
expect(api.restSearches).toBe(29)
|
||||
})
|
||||
|
||||
it('keeps REST fallback on the credential captured for the failed preferred search', async () => {
|
||||
vi.stubEnv('GH_TOKEN', 'fixture-original-credential')
|
||||
api.aliasErrorRepo = 'fixture/repo'
|
||||
|
||||
Reference in New Issue
Block a user