Skip to content

Commit

Permalink
[parents_migrations] add front migration for github (#9447)
Browse files Browse the repository at this point in the history
* add front migration for github

* fix migration function

* keep unique values only
  • Loading branch information
aubin-tchoi authored Dec 17, 2024
1 parent 589ea63 commit f93edef
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion front/migrations/20241211_parents_front_migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,38 @@ const migrators: Record<ConnectorProvider, ProviderMigrator | null> = {
: `gdrive-${parent}`
),
microsoft: null,
github: null,
github: (parents) => {
return [
...new Set(
parents.map((parent) => {
if (/^\d+$/.test(parent)) {
return `github-repository-${parent}`;
}
if (/\d+-issues$/.test(parent)) {
const repoId = parseInt(parent.replace(/-issues$/, ""), 10);
return `github-issues-${repoId}`;
}
if (/\d+-discussions$/.test(parent)) {
const repoId = parseInt(parent.replace(/-discussions$/, ""), 10);
return `github-discussions-${repoId}`;
}
if (
/^github-code-\d+$/.test(parent) ||
/^github-code-\d+-dir-[a-f0-9]+$/.test(parent) ||
/^github-code-\d+-file-[a-f0-9]+$/.test(parent) ||
/^github-discussions-\d+$/.test(parent) ||
/^github-discussion-\d+$/.test(parent) ||
/^github-issues-\d+$/.test(parent) ||
/^github-issue-\d+$/.test(parent) ||
/^github-repository-\d+$/.test(parent)
) {
return parent;
}
throw new Error(`Unrecognized parent type: ${parent}`);
})
),
];
},
notion: (parents) => {
return _.uniq(parents.map((p) => _.last(p.split("notion-"))!)).map(
(id) => `notion-${id}`
Expand Down

0 comments on commit f93edef

Please sign in to comment.