Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/cache-4
Browse files Browse the repository at this point in the history
  • Loading branch information
ipc103 authored Mar 4, 2024
2 parents d1ee7e9 + bfd2fbc commit d183d23
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 59 deletions.
11 changes: 10 additions & 1 deletion ts-backend/src/fetchers/repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Fetchers for repository data and metrics

import { Organization, Repository } from "@octokit/graphql-schema";
import { Fetcher, RepositoryResult } from "..";
import { Fetcher } from "..";
import { RepositoryResult } from '../../../types'

export const addRepositoriesToResult: Fetcher = async (
result,
Expand Down Expand Up @@ -48,6 +49,13 @@ export const addRepositoriesToResult: Fetcher = async (
collaborators {
totalCount
}
repositoryTopics(first: 20) {
nodes {
topic {
name
}
}
}
}
}
}
Expand All @@ -73,6 +81,7 @@ export const addRepositoriesToResult: Fetcher = async (
repositoryName: repo.name,
repoNameWithOwner: repo.nameWithOwner,
licenseName: repo.licenseInfo?.name || "No License",
topics: repo.repositoryTopics.nodes?.map((node) => node?.topic.name ),
forksCount: repo.forkCount,
watchersCount: repo.watchers.totalCount,
starsCount: repo.stargazerCount,
Expand Down
37 changes: 1 addition & 36 deletions ts-backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
addRepositoriesToResult,
} from "./fetchers";
import { checkRateLimit, CustomOctokit, personalOctokit } from "./lib/octokit";
import { RepositoryResult } from '../../types'

export interface Result {
meta: {
Expand All @@ -31,42 +32,6 @@ export interface Result {
repositories: Record<string, RepositoryResult>;
}

export interface RepositoryResult {
// Repo metadata
repositoryName: string;
repoNameWithOwner: string;
licenseName: string;

// Counts of various things
projectsCount: number;
projectsV2Count: number;
discussionsCount: number;
forksCount: number;
totalIssuesCount: number;
openIssuesCount: number;
closedIssuesCount: number;
totalPullRequestsCount: number;
openPullRequestsCount: number;
closedPullRequestsCount: number;
mergedPullRequestsCount: number;
watchersCount: number;
starsCount: number;
collaboratorsCount: number;

// Flags
discussionsEnabled: boolean;
projectsEnabled: boolean;
issuesEnabled: boolean;

// Calculated metrics
openIssuesAverageAge: number;
openIssuesMedianAge: number;
closedIssuesAverageAge: number;
closedIssuesMedianAge: number;
issuesResponseAverageAge: number;
issuesResponseMedianAge: number;
}

export type Fetcher = (
result: Result,
octokit: CustomOctokit,
Expand Down
36 changes: 36 additions & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export interface RepositoryResult {
// Repo metadata
repositoryName: string;
repoNameWithOwner: string;
licenseName: string;
topics: string[];

// Counts of various things
projectsCount: number;
projectsV2Count: number;
discussionsCount: number;
forksCount: number;
totalIssuesCount: number;
openIssuesCount: number;
closedIssuesCount: number;
totalPullRequestsCount: number;
openPullRequestsCount: number;
closedPullRequestsCount: number;
mergedPullRequestsCount: number;
watchersCount: number;
starsCount: number;
collaboratorsCount: number;

// Flags
discussionsEnabled: boolean;
projectsEnabled: boolean;
issuesEnabled: boolean;

// Calculated metrics
openIssuesAverageAge: number;
openIssuesMedianAge: number;
closedIssuesAverageAge: number;
closedIssuesMedianAge: number;
issuesResponseAverageAge: number;
issuesResponseMedianAge: number;
}
Loading

0 comments on commit d183d23

Please sign in to comment.