Third entity: Github fork
This commit is contained in:
@@ -3,9 +3,9 @@ import { Connection, ConnectionOptions, createConnection } from 'typeorm';
|
||||
import { logUtils } from '@0x/utils';
|
||||
|
||||
import { GithubSource } from '../data_sources/github';
|
||||
import { GithubPullRequest, GithubRepo } from '../entities';
|
||||
import { GithubFork, GithubPullRequest, GithubRepo } from '../entities';
|
||||
import * as ormConfig from '../ormconfig';
|
||||
import { parseGithubPulls, parseGithubRepo } from '../parsers/github';
|
||||
import { parseGithubForks, parseGithubPulls, parseGithubRepo } from '../parsers/github';
|
||||
import { handleError } from '../utils';
|
||||
|
||||
const GITHUB_OWNER = '0xProject';
|
||||
@@ -41,5 +41,19 @@ let connection: Connection;
|
||||
await GithubPullRequestRepository.save(pulls);
|
||||
}
|
||||
|
||||
// get forks and save
|
||||
const GithubForkRepository = connection.getRepository(GithubFork);
|
||||
numberOfRecords = RECORDS_PER_PAGE;
|
||||
page = 1;
|
||||
while (numberOfRecords === RECORDS_PER_PAGE) {
|
||||
logUtils.log(`Fetching Github forks from API, page: ${page}.`);
|
||||
const rawForks = await githubSource.getGithubForksAsync(page);
|
||||
const forks = parseGithubForks(rawForks, observedTimestamp);
|
||||
numberOfRecords = forks.length;
|
||||
page++;
|
||||
logUtils.log(`Saving ${forks.length} forks to database.`);
|
||||
await GithubForkRepository.save(forks);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
})().catch(handleError);
|
||||
|
Reference in New Issue
Block a user