Skip to content

Commit c64e791

Browse files
committed
fix(sync): fix github pagination
1 parent 8114e4d commit c64e791

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

jobs/sync-repos.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ const { flatten } = require('lodash')
66
const dbs = require('../lib/dbs')
77
const githubQueue = require('../lib/github-queue')
88
const { createDocs } = require('../lib/repository-docs')
9+
const GitHub = require('../../../lib/github')
10+
const getToken = require('../../../lib/get-token')
911

1012
module.exports = async function ({ accountId }) {
13+
const { installations, repositories } = await dbs()
1114
const logs = dbs.getLogsDb()
12-
const log = Log({ logsDb: logs, accountId: accountId, repoSlug: null, context: 'sync-repositories' })
15+
const log = Log({ logsDb: logs, accountId: accountId, repoSlug: null, context: 'sync-repos' })
1316
log.info(`started`)
1417

15-
const { installations, repositories } = await dbs()
1618
const installation = await installations.get(String(accountId))
1719
const installationId = installation.installation
1820

@@ -32,13 +34,15 @@ module.exports = async function ({ accountId }) {
3234
}
3335

3436
try {
35-
const options = await githubQueue(installationId).read(github => github.apps.listRepos.endpoint.merge({
37+
const { token } = await getToken(installationId)
38+
const github = GitHub({ auth: `token ${token}` })
39+
const options = github.apps.listRepos.endpoint.merge({
3640
headers: {
3741
accept: 'application/vnd.github.machine-man-preview+json'
3842
},
3943
org: 'neighbourhoodie',
4044
per_page: 100
41-
}))
45+
})
4246

4347
// Paginate does not actually flatten results into a single result array
4448
// as it should, according to the docs, possibly due to these:

0 commit comments

Comments
 (0)