- Added github:init to allow full import, as opposed to gitHub:sync which allows partial sync and therefore respecting Github API Limit quota. --------- Co-authored-by: Ady Beraud <a.beraud96@gmail.com>
28 lines
662 B
TypeScript
28 lines
662 B
TypeScript
import { graphql } from '@octokit/graphql';
|
|
|
|
import { insertMany } from '@/database/database';
|
|
import { githubStarsModel } from '@/database/model';
|
|
import { Repository } from '@/github/contributors/types';
|
|
|
|
export const fetchAndSaveGithubStars = async (
|
|
query: typeof graphql,
|
|
): Promise<void> => {
|
|
const { repository } = await query<Repository>(`
|
|
query {
|
|
repository(owner: "twentyhq", name: "twenty") {
|
|
stargazers {
|
|
totalCount
|
|
}
|
|
}
|
|
}
|
|
`);
|
|
|
|
const numberOfStars = repository.stargazers.totalCount;
|
|
|
|
await insertMany(githubStarsModel, [
|
|
{
|
|
numberOfStars,
|
|
},
|
|
]);
|
|
};
|