Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct total repos count #19

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ const httpServer = createServer(async (request, response) => {
// "Only on this account" when registering the app.

const installations = [];
await OctokitApp.app.eachInstallation(async octokit => {
await OctokitApp.app.eachInstallation(async (octokit) => {
const name = octokit.installation.account.login;
const repos = await getReposForInstallation(octokit);

const { repos, totalRepos } = await getReposForInstallation(octokit);

installations.push({
name,
repos,
totalRepos,
});
});

Expand All @@ -39,9 +40,12 @@ const getReposForInstallation = async ({ octokit, installation }) => {
return octokit
.request(installation.repositories_url)
.then(({ data }) => {
return data.repositories.map((repo) => ({
const repos = data.repositories.map((repo) => ({
name: repo.name,
}));
const totalRepos = data.total_count;

return { repos, totalRepos };
})
.catch((error) => {
console.error(error);
Expand Down
4 changes: 2 additions & 2 deletions index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<div class="bg-stone-50 overflow-hidden rounded-lg border-b-4 border-stone-200 space-y-4">
<h2 class="bg-white border-b-2 border-stone-100 text-xl font-bold p-4">{{ name }}</h2>
<p class="mx-4">
{% if repos.length === 1 %}
{% if totalRepos === 1 %}
There is <span class="font-bold">1</span> repository
{% else %}
There are <span class="font-bold">{{ repos.length }}</span> repositories
There are <span class="font-bold">{{ totalRepos }}</span> repositories
{% endif %}
that Towtruck is tracking for <span class="font-bold">{{ name }}</span>.
</p>
Expand Down
Loading