Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Aug 23, 2024
1 parent bd4c204 commit a90476e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const ConfigureJobAgentGithub: React.FC<{
installationId: jobAgent.config.installationId,
});

console.log({ repos: repos.data });

const [repoOpen, setRepoOpen] = useState(false);
const [repo, setRepo] = useState<string | null>(value.repo ?? null);

Expand Down Expand Up @@ -97,7 +95,7 @@ export const ConfigureJobAgentGithub: React.FC<{
<CommandInput placeholder="Search repo..." />
<CommandGroup>
<CommandList>
{repos.data?.map((repo) => (
{repos.data?.data.map((repo) => (
<CommandItem
key={repo.id}
value={repo.name}
Expand Down
28 changes: 7 additions & 21 deletions packages/api/src/router/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,13 @@ const reposRouter = createTRPCRouter({
installationId: installation.id,
})) as { token: string };

const searchResponse = await installationOctokit.search.code({
q: `org:${input.login} filename:example.ctrlplane.yaml`,
per_page: 100,
return installationOctokit.repos.listForOrg({
org: input.login,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
authorization: `Bearer ${installationToken.token}`,
},
});

return installationOctokit.repos
.listForOrg({
org: input.login,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
authorization: `Bearer ${installationToken.token}`,
},
})
.then(({ data }) =>
data.map((repo) => ({
...repo,
configFiles: searchResponse.data.items.filter(
(item) => item.repository.full_name === repo.full_name,
),
})),
);
}),
),

Expand Down Expand Up @@ -319,7 +301,7 @@ export const githubRouter = createTRPCRouter({
data: { items: configFiles },
} = searchResponse;

const parsedConfigFiles = await Promise.all(
const parsedConfigFiles = await Promise.allSettled(
configFiles.map(async (cf) => {
const content = await installationOctokit.repos
.getContent({
Expand Down Expand Up @@ -349,6 +331,10 @@ export const githubRouter = createTRPCRouter({
content: parsed.data,
};
}),
).then((results) =>
results
.map((r) => (r.status === "fulfilled" ? r.value : null))
.filter(isPresent),
);

const deploymentInfo = await db
Expand Down

0 comments on commit a90476e

Please sign in to comment.