diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 00000000..0050b13b Binary files /dev/null and b/public/logo.png differ diff --git a/scraper/src/github-scraper/fetchUserData.ts b/scraper/src/github-scraper/fetchUserData.ts index 95c90344..4d962ba2 100644 --- a/scraper/src/github-scraper/fetchUserData.ts +++ b/scraper/src/github-scraper/fetchUserData.ts @@ -52,7 +52,7 @@ export const fetchOpenPulls = async (user: string, org: string) => { link: pr.html_url, title: pr.title, stale_for: staleFor, - labels: pr.labels.map((label: { name: string }) => label.name), + labels: pr.labels.map((label: { name?: string }) => label.name), }; }); diff --git a/scraper/src/github-scraper/index.ts b/scraper/src/github-scraper/index.ts index 2c66845f..53a18c05 100644 --- a/scraper/src/github-scraper/index.ts +++ b/scraper/src/github-scraper/index.ts @@ -1,5 +1,5 @@ import { formatISO, parseISO, startOfDay, subDays } from "date-fns"; -import { ProcessData } from "./types.js"; +import { IGitHubEvent, ProcessData } from "./types.js"; import { fetchMergeEvents, fetchOpenPulls } from "./fetchUserData.js"; import { fetchEvents } from "./fetchEvents.js"; import { parseEvents } from "./parseEvents.js"; @@ -19,9 +19,8 @@ const scrapeGitHub = async ( console.log( `Scraping GitHub data for ${org} from ${formatISO(startDate)} to ${formatISO(endDate)}`, ); - const events = await fetchEvents(org, startDate, endDate); - processedData = await parseEvents(events); + processedData = await parseEvents(events as IGitHubEvent[]); for (const user of Object.keys(processedData)) { if (!processedData[user]) { processedData[user] = { diff --git a/scraper/src/github-scraper/parseEvents.ts b/scraper/src/github-scraper/parseEvents.ts index 40574509..0c9bc4b1 100644 --- a/scraper/src/github-scraper/parseEvents.ts +++ b/scraper/src/github-scraper/parseEvents.ts @@ -8,7 +8,6 @@ import { calculateTurnaroundTime } from "./utils.js"; import { parseISO } from "date-fns"; import { isBlacklisted } from "./utils.js"; import { octokit } from "./config.js"; - const processedData: ProcessData = {}; function appendEvent(user: string, event: Activity) { @@ -136,7 +135,7 @@ export const parseEvents = async (events: IGitHubEvent[]) => { appendEvent(user, { type: "comment_created", title: `${event.repo.name}#${event.payload.issue.number}`, - time: eventTime.toISOString(), + time: eventTime?.toISOString(), link: event.payload.comment.html_url, text: event.payload.comment.body, }); @@ -146,7 +145,7 @@ export const parseEvents = async (events: IGitHubEvent[]) => { if (["opened", "assigned", "closed"].includes(event.payload.action)) { appendEvent(user, { type: `issue_${event.payload.action}`, - title: `${event.repo.name}#${event.payload.issue?.number}`, + title: `${event.repo.name}#${event.payload.issue.number}`, time: eventTime.toISOString(), link: event.payload.issue.html_url, text: event.payload.issue.title, @@ -170,7 +169,7 @@ export const parseEvents = async (events: IGitHubEvent[]) => { appendEvent(user, { type: "pr_merged", title: `${event.repo.name}#${event.payload.pull_request.number}`, - time: eventTime.toISOString(), + time: eventTime?.toISOString(), link: event.payload.pull_request.html_url, text: event.payload.pull_request.title, turnaround_time: turnaroundTime, @@ -181,7 +180,7 @@ export const parseEvents = async (events: IGitHubEvent[]) => { case "PullRequestReviewEvent": appendEvent(user, { type: "pr_reviewed", - time: eventTime.toISOString(), + time: eventTime?.toISOString(), title: `${event.repo.name}#${event.payload.pull_request.number}`, link: event.payload.review.html_url, text: event.payload.pull_request.title, diff --git a/scraper/src/github-scraper/types.ts b/scraper/src/github-scraper/types.ts index 332324f4..aacce91e 100644 --- a/scraper/src/github-scraper/types.ts +++ b/scraper/src/github-scraper/types.ts @@ -164,7 +164,7 @@ export interface OpenPr { link: string; title: string; stale_for: number; - labels: string[]; + labels: (string | undefined)[]; } export interface AuthoredIssueAndPr { diff --git a/scraper/src/github-scraper/utils.ts b/scraper/src/github-scraper/utils.ts index 31d81cf7..e2fdddc6 100644 --- a/scraper/src/github-scraper/utils.ts +++ b/scraper/src/github-scraper/utils.ts @@ -28,11 +28,10 @@ export async function calculateTurnaroundTime(event: PullRequestEvent) { `GET ${event.payload?.pull_request?.issue_url}`, ); // Fetch url all linked issues url from the response - // What if the issue was cross-referenced from another repository than the repository of the PR made also add this feature linkedIssues.push([event.repo.name, `#${linkedIssuesResponse.data.number}`]); // Fetch issue events to find cross-referenced issues - const issueEventsUrl = linkedIssuesResponse.data.events_url; + const issueEventsUrl = await linkedIssuesResponse.data.events_url; const issueEventsResponse = await octokit.request(`GET ${issueEventsUrl}`); type issueEvent = typeof issueEventsResponse.data; @@ -97,9 +96,8 @@ export async function calculateTurnaroundTime(event: PullRequestEvent) { issue_number: issueNumber, }, ); - - const issueTimeline = issueTimelineResponse.data; - issueTimeline.forEach((action: Action) => { + type Action = (typeof issueTimelineResponse.data)[0]; + issueTimelineResponse.data.forEach((action: Action) => { if (action.event === "assigned" && action.assignee.login === user) { assignedAts.push({ issue: `${org}/${repo}#${issueNumber}`,