Files
twenty/packages/twenty-website/src/github/github-releases/fetch-and-save-github-releases.tsx
T
Ady Beraud 4a7aabd060 Added GitHub init (#5317)
- 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>
2024-05-13 09:55:30 +02:00

27 lines
720 B
TypeScript

import { graphql } from '@octokit/graphql';
import { insertMany } from '@/database/database';
import { githubReleasesModel } from '@/database/model';
import { Repository } from '@/github/contributors/types';
export const fetchAndSaveGithubReleases = async (
query: typeof graphql,
): Promise<void> => {
const { repository } = await query<Repository>(`
query {
repository(owner: "twentyhq", name: "twenty") {
releases(first: 100) {
nodes {
tagName
publishedAt
}
}
}
}
`);
await insertMany(githubReleasesModel, repository.releases.nodes, {
onConflictKey: 'tagName',
});
};