From 245bd81703691376563349ad851fcc91e3b7eceb Mon Sep 17 00:00:00 2001 From: Vaibhav Patil Date: Sat, 19 Oct 2024 23:49:45 +0530 Subject: [PATCH 1/6] feat:fixed Responsiveness for Graduate Attributes in Contributor Page #523 --- app/contributors/VAIBHAVSING.md | 10 ++++++++++ app/contributors/[slug]/page.tsx | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 app/contributors/VAIBHAVSING.md diff --git a/app/contributors/VAIBHAVSING.md b/app/contributors/VAIBHAVSING.md new file mode 100644 index 00000000..c0ce4d47 --- /dev/null +++ b/app/contributors/VAIBHAVSING.md @@ -0,0 +1,10 @@ +--- +name: Vaibhav patil +title: Full Stack Developer +github: VAIBHAVSING +twitter: Vsing11 +linkedin: vaibhavpatil24 +slack: U07RZSC99M1 +joining_date: "19/10/2024" +role: contributor +--- \ No newline at end of file diff --git a/app/contributors/[slug]/page.tsx b/app/contributors/[slug]/page.tsx index d410d73e..c7584dd1 100644 --- a/app/contributors/[slug]/page.tsx +++ b/app/contributors/[slug]/page.tsx @@ -142,8 +142,8 @@ export default async function Page({ params }: Params) {
-
-
+
+

Individual Skills From 5622d02910763df7989e8af4b0ea74b17615ee37 Mon Sep 17 00:00:00 2001 From: Vaibhav Patil <154789507+VAIBHAVSING@users.noreply.github.com> Date: Sun, 20 Oct 2024 13:42:45 +0530 Subject: [PATCH 2/6] Delete app/contributors/VAIBHAVSING.md --- app/contributors/VAIBHAVSING.md | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 app/contributors/VAIBHAVSING.md diff --git a/app/contributors/VAIBHAVSING.md b/app/contributors/VAIBHAVSING.md deleted file mode 100644 index c0ce4d47..00000000 --- a/app/contributors/VAIBHAVSING.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Vaibhav patil -title: Full Stack Developer -github: VAIBHAVSING -twitter: Vsing11 -linkedin: vaibhavpatil24 -slack: U07RZSC99M1 -joining_date: "19/10/2024" -role: contributor ---- \ No newline at end of file From 26d0b6c28b45152c01a523a325af5c5c0fa1deac Mon Sep 17 00:00:00 2001 From: Vaibhav Patil Date: Tue, 22 Oct 2024 00:24:10 +0530 Subject: [PATCH 3/6] Card align with Graduate Attributes card in mobile view --- app/contributors/[slug]/page.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/contributors/[slug]/page.tsx b/app/contributors/[slug]/page.tsx index c7584dd1..1e92f8bb 100644 --- a/app/contributors/[slug]/page.tsx +++ b/app/contributors/[slug]/page.tsx @@ -119,7 +119,7 @@ export default async function Page({ params }: Params) {

)} -
+

Graduate Attributes

-
-
+
+

Individual Skills @@ -160,7 +160,7 @@ export default async function Page({ params }: Params) { ))}

-
+

Team Skills @@ -177,7 +177,7 @@ export default async function Page({ params }: Params) { ))}

-
+
{advancedSkills.map((skill) => (
-
+
{humanValues.map((skill) => ( Date: Tue, 29 Oct 2024 16:55:42 +0530 Subject: [PATCH 4/6] Feat:Duplicate PR collaboration activities #531 --- scraper/src/github-scraper/parseEvents.ts | 46 +++++++++++++++-------- scraper/src/github-scraper/types.ts | 1 + 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/scraper/src/github-scraper/parseEvents.ts b/scraper/src/github-scraper/parseEvents.ts index 6053152a..62671a26 100644 --- a/scraper/src/github-scraper/parseEvents.ts +++ b/scraper/src/github-scraper/parseEvents.ts @@ -9,7 +9,19 @@ import { parseISO } from "date-fns"; import { isBlacklisted } from "./utils.js"; import { octokit } from "./config.js"; const processedData: ProcessData = {}; - +async function fetchdefaultbranch(org: string, repo: string) { + try { + const { data } = await octokit.request('GET /repos/{owner}/{repo}', { + owner: org, + repo: repo, + }); + return data.default_branch; + } catch (e) { + console.error( + `Error fetching default branch for organisation ${org} /${repo} `, + ); + } +} function appendEvent(user: string, event: Activity) { console.log(`Appending event for ${user}`); if (!processedData[user]) { @@ -33,7 +45,8 @@ const emailUserCache: { [key: string]: string } = {}; async function addCollaborations(event: PullRequestEvent, eventTime: Date) { const collaborators: Set = new Set(); - + const repo = event.repo.name.split('/'); + const default_branch = await fetchdefaultbranch(repo[0], repo[1]) const url: string | undefined = event.payload.pull_request?.commits_url; const response = await octokit.request("GET " + url); @@ -105,19 +118,22 @@ async function addCollaborations(event: PullRequestEvent, eventTime: Date) { if (collaborators.size > 1) { const collaboratorArray = Array.from(collaborators); // Convert Set to Array - for (const user of collaboratorArray) { - const others = new Set(collaborators); - const othersArray = Array.from(others); - - others.delete(user); - appendEvent(user, { - type: "pr_collaborated", - title: `${event.repo.name}#${event.payload.pull_request.number}`, - time: eventTime.toISOString(), - link: event.payload.pull_request.html_url, - text: event.payload.pull_request.title, - collaborated_with: [...othersArray], - }); + if (event.payload.pull_request.base.ref === default_branch) { + for (const user of collaboratorArray) { + const others = new Set(collaborators); + const othersArray = Array.from(others); + + others.delete(user); + + appendEvent(user, { + type: "pr_collaborated", + title: `${event.repo.name}#${event.payload.pull_request.number}`, + time: eventTime.toISOString(), + link: event.payload.pull_request.html_url, + text: event.payload.pull_request.title, + collaborated_with: [...othersArray], + }); + } } } } diff --git a/scraper/src/github-scraper/types.ts b/scraper/src/github-scraper/types.ts index 668cb98d..7dadb5b5 100644 --- a/scraper/src/github-scraper/types.ts +++ b/scraper/src/github-scraper/types.ts @@ -15,6 +15,7 @@ interface Comment { } export interface PullRequest { + base: any; html_url: string; user: Actor; title: string; From 9a71d7f6e1cd0f2679b281b2d330029b1ce65e55 Mon Sep 17 00:00:00 2001 From: Vaibhav Patil Date: Wed, 30 Oct 2024 16:26:33 +0530 Subject: [PATCH 5/6] fixes typos and follow naming convention closes #531 --- scraper/src/github-scraper/parseEvents.ts | 12 +++++++----- scraper/src/github-scraper/types.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scraper/src/github-scraper/parseEvents.ts b/scraper/src/github-scraper/parseEvents.ts index 62671a26..81589a31 100644 --- a/scraper/src/github-scraper/parseEvents.ts +++ b/scraper/src/github-scraper/parseEvents.ts @@ -9,8 +9,12 @@ import { parseISO } from "date-fns"; import { isBlacklisted } from "./utils.js"; import { octokit } from "./config.js"; const processedData: ProcessData = {}; -async function fetchdefaultbranch(org: string, repo: string) { +const DefaultBranch = new Map(); +async function getDefaultBranch(org: string, repo: string) { try { + if (DefaultBranch.has(`${org}/${repo}`)) { + return DefaultBranch.get(`${org}/${repo}`); + } const { data } = await octokit.request('GET /repos/{owner}/{repo}', { owner: org, repo: repo, @@ -46,7 +50,7 @@ const emailUserCache: { [key: string]: string } = {}; async function addCollaborations(event: PullRequestEvent, eventTime: Date) { const collaborators: Set = new Set(); const repo = event.repo.name.split('/'); - const default_branch = await fetchdefaultbranch(repo[0], repo[1]) + const default_branch = await getDefaultBranch(repo[0], repo[1]) const url: string | undefined = event.payload.pull_request?.commits_url; const response = await octokit.request("GET " + url); @@ -116,9 +120,8 @@ async function addCollaborations(event: PullRequestEvent, eventTime: Date) { } } - if (collaborators.size > 1) { + if (collaborators.size > 1 && event.payload.pull_request.base.ref === default_branch) { const collaboratorArray = Array.from(collaborators); // Convert Set to Array - if (event.payload.pull_request.base.ref === default_branch) { for (const user of collaboratorArray) { const others = new Set(collaborators); const othersArray = Array.from(others); @@ -133,7 +136,6 @@ async function addCollaborations(event: PullRequestEvent, eventTime: Date) { text: event.payload.pull_request.title, collaborated_with: [...othersArray], }); - } } } } diff --git a/scraper/src/github-scraper/types.ts b/scraper/src/github-scraper/types.ts index 7dadb5b5..c765e695 100644 --- a/scraper/src/github-scraper/types.ts +++ b/scraper/src/github-scraper/types.ts @@ -15,7 +15,7 @@ interface Comment { } export interface PullRequest { - base: any; + base:{ref:string}; html_url: string; user: Actor; title: string; From ceeb3b80c0f4416e4275281b6e4199d04ea43264 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 30 Oct 2024 17:11:29 +0530 Subject: [PATCH 6/6] fix cache not being used and improve code quality --- scraper/src/github-scraper/parseEvents.ts | 71 ++++++++++++----------- scraper/src/github-scraper/types.ts | 13 ++++- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/scraper/src/github-scraper/parseEvents.ts b/scraper/src/github-scraper/parseEvents.ts index 81589a31..21cf13cc 100644 --- a/scraper/src/github-scraper/parseEvents.ts +++ b/scraper/src/github-scraper/parseEvents.ts @@ -8,23 +8,23 @@ import { calculateTurnaroundTime } from "./utils.js"; import { parseISO } from "date-fns"; import { isBlacklisted } from "./utils.js"; import { octokit } from "./config.js"; + const processedData: ProcessData = {}; -const DefaultBranch = new Map(); -async function getDefaultBranch(org: string, repo: string) { - try { - if (DefaultBranch.has(`${org}/${repo}`)) { - return DefaultBranch.get(`${org}/${repo}`); +const defaultBranches: Record = {}; + +async function getDefaultBranch(owner: string, repo: string) { + if (defaultBranches[repo] == null) { + try { + const { data } = await octokit.request("GET /repos/{owner}/{repo}", { + owner, + repo, + }); + defaultBranches[repo] = data.default_branch; + } catch (e) { + console.error(`Error fetching default branch for ${owner}/${repo} `); } - const { data } = await octokit.request('GET /repos/{owner}/{repo}', { - owner: org, - repo: repo, - }); - return data.default_branch; - } catch (e) { - console.error( - `Error fetching default branch for organisation ${org} /${repo} `, - ); } + return defaultBranches[repo]; } function appendEvent(user: string, event: Activity) { console.log(`Appending event for ${user}`); @@ -49,12 +49,15 @@ const emailUserCache: { [key: string]: string } = {}; async function addCollaborations(event: PullRequestEvent, eventTime: Date) { const collaborators: Set = new Set(); - const repo = event.repo.name.split('/'); - const default_branch = await getDefaultBranch(repo[0], repo[1]) - const url: string | undefined = event.payload.pull_request?.commits_url; - const response = await octokit.request("GET " + url); - const commits = response.data; + const [owner, repo] = event.repo.name.split("/"); + const defaultBranch = await getDefaultBranch(owner, repo); + if (event.payload.pull_request.base.ref !== defaultBranch) { + return; + } + + const url = event.payload.pull_request?.commits_url; + const { data: commits } = await octokit.request("GET " + url); for (const commit of commits) { // Merge commits has more than 1 parent commits; skip merge commit authors from being counted as collaborators if (commit.parents.length > 1) { @@ -120,22 +123,20 @@ async function addCollaborations(event: PullRequestEvent, eventTime: Date) { } } - if (collaborators.size > 1 && event.payload.pull_request.base.ref === default_branch) { - const collaboratorArray = Array.from(collaborators); // Convert Set to Array - for (const user of collaboratorArray) { - const others = new Set(collaborators); - const othersArray = Array.from(others); - - others.delete(user); - - appendEvent(user, { - type: "pr_collaborated", - title: `${event.repo.name}#${event.payload.pull_request.number}`, - time: eventTime.toISOString(), - link: event.payload.pull_request.html_url, - text: event.payload.pull_request.title, - collaborated_with: [...othersArray], - }); + if (collaborators.size > 1) { + const collaboratorArray = Array.from(collaborators); + for (const user of collaboratorArray) { + const others = new Set(collaborators); + const othersArray = Array.from(others); + others.delete(user); + appendEvent(user, { + type: "pr_collaborated", + title: `${event.repo.name}#${event.payload.pull_request.number}`, + time: eventTime.toISOString(), + link: event.payload.pull_request.html_url, + text: event.payload.pull_request.title, + collaborated_with: [...othersArray], + }); } } } diff --git a/scraper/src/github-scraper/types.ts b/scraper/src/github-scraper/types.ts index c765e695..942c54cc 100644 --- a/scraper/src/github-scraper/types.ts +++ b/scraper/src/github-scraper/types.ts @@ -15,7 +15,18 @@ interface Comment { } export interface PullRequest { - base:{ref:string}; + base: { + label: string; + ref: string; + sha: string; + user: Actor; + }; + head: { + label: string; + ref: string; + sha: string; + user: Actor; + }; html_url: string; user: Actor; title: string;