From ea18382165952c426b0c3eb4acb66421fa742b57 Mon Sep 17 00:00:00 2001 From: Brian 'bdougie' Douglas Date: Thu, 15 Aug 2024 19:21:50 -0700 Subject: [PATCH 1/3] replaces velocity with oscr --- src/popup/pages/profile.tsx | 407 +++++++++++++++++++----------------- 1 file changed, 214 insertions(+), 193 deletions(-) diff --git a/src/popup/pages/profile.tsx b/src/popup/pages/profile.tsx index 2c0a80e7..50b880b2 100644 --- a/src/popup/pages/profile.tsx +++ b/src/popup/pages/profile.tsx @@ -1,13 +1,28 @@ import { useEffect, useState } from "react"; import { FaBrain, FaChevronLeft, FaRobot } from "react-icons/fa"; import { RiLinkedinFill, RiLinkM, RiTwitterFill } from "react-icons/ri"; -import { SiC, SiCplusplus, SiCsharp, SiGoland, SiJavascript, SiPhp, SiPython, SiReact, SiRuby, SiRust, SiTypescript } from "react-icons/si"; +import { + SiC, + SiCplusplus, + SiCsharp, + SiGoland, + SiJavascript, + SiPhp, + SiPython, + SiReact, + SiRuby, + SiRust, + SiTypescript, +} from "react-icons/si"; import { DiJava } from "react-icons/di"; import OpenSaucedLogo from "../../assets/opensauced-logo.svg"; -import { getUserData, getUserPRData, getUserHighlightsData } from "../../utils/fetchOpenSaucedApiData"; +import { + getUserData, + getUserPRData, + getUserHighlightsData, +} from "../../utils/fetchOpenSaucedApiData"; import { emojify } from "node-emoji"; import { goBack, goTo } from "react-chrome-extension-router"; -import { getRelativeDays } from "../../utils/dateUtils"; import { countUniqueRepos, PRResponse } from "../../utils/getContributedRepos"; import { getUserPRVelocity } from "../../utils/getUserPRVelocity"; import { BiExit } from "react-icons/bi"; @@ -16,200 +31,206 @@ import { optLogOut } from "../../utils/checkAuthentication"; import { OPEN_SAUCED_INSIGHTS_DOMAIN } from "../../constants"; const interestIcon = { - python: , - java: , - javascript: , - typescript: , - csharp: , - cpp: , - c: , - php: , - ruby: , - react: , - ml: , - ai: , - golang: , - rust: , + python: , + java: , + javascript: , + typescript: , + csharp: , + cpp: , + c: , + php: , + ruby: , + react: , + ml: , + ai: , + golang: , + rust: , }; type InterestIconKeys = keyof typeof interestIcon; export const Profile = ({ username }: { username: string }) => { - const [user, setUser] = useState(null); - const [userPR, setUserPR] = useState(null); - const [userHighlights, setUserHighlights] = useState(null); - const [userPRVelocity, setUserPRVelocity] = useState(0); - - useEffect(() => { - const fetchUserData = async () => { - const [userData, userPRData, userHighlightsData] = await Promise.all([getUserData(username), getUserPRData(username), getUserHighlightsData(username)]); - - setUser(userData); - setUserPR(userPRData); - setUserHighlights(userHighlightsData); - setUserPRVelocity(getUserPRVelocity(userPRData?.data || [])); - }; - - void fetchUserData(); - }, []); - - - return ( -
-
-
-
- - - OpenSauced logo -
- - -
- -
-
- - User avatar - -

- @ - {username} -

-
- - {(user?.linkedin_url || user?.twitter_username) && -
- {user.linkedin_url && - - - } - - {user.twitter_username && - - - } -
} - - {user?.bio && ( - - {emojify(user.bio)} - - )} - - {user?.blog && - - - - {user.blog} - } -
- -
-
-

Total Highlights

- -

- {userHighlights?.meta.itemCount} -

-
- -
-

PR Count

- -

- {userPR?.meta.itemCount} -

-
- -
-

Avg PRs Velocity

- -

- {getRelativeDays(userPRVelocity)} -

-
- -
-

Contributed Repos

- -

- {countUniqueRepos(userPR)} -

-
-
- -
-

Current Interest

- -
- {user?.interests.split(",").map(interest => ( - - {interestIcon[interest as InterestIconKeys]} - - {interest} - - ))} -
-
-
+ const [user, setUser] = useState(null); + const [userPR, setUserPR] = useState(null); + const [userHighlights, setUserHighlights] = useState(null); + const [_, setUserPRVelocity] = useState(0); + + useEffect(() => { + const fetchUserData = async () => { + const [userData, userPRData, userHighlightsData] = await Promise.all([ + getUserData(username), + getUserPRData(username), + getUserHighlightsData(username), + ]); + + setUser(userData); + setUserPR(userPRData); + setUserHighlights(userHighlightsData); + setUserPRVelocity(getUserPRVelocity(userPRData?.data || [])); + }; + + void fetchUserData(); + }, []); + + return ( +
+
+
+
+ + + OpenSauced logo +
+ + +
+ +
+
+ + User avatar + +

@{username}

+
+ + {(user?.linkedin_url || user?.twitter_username) && ( +
+ {user.linkedin_url && ( + + + + )} + + {user.twitter_username && ( + + + + )} +
+ )} + + {user?.bio && {emojify(user.bio)}} + + {user?.blog && ( + + + + {user.blog} + + )} +
+ +
+
+

Total Highlights

+ +

+ {userHighlights?.meta.itemCount} +

-
- ); + +
+

PR Count

+ +

{userPR?.meta.itemCount}

+
+ +
+

OSCR

+ + {user?.bio && ( +

{Math.ceil(user.oscr)}

+ )} +
+ +
+

Contributed Repos

+ +

{countUniqueRepos(userPR)}

+
+
+ +
+

Current Interest

+ +
+ {user?.interests.split(",").map((interest) => ( + + {interestIcon[interest as InterestIconKeys]} + + {interest} + + ))} +
+
+ +
+
+ ); }; From 9ff5a4f5f07ad8e881b837d5435cc6a634202f37 Mon Sep 17 00:00:00 2001 From: Brian 'bdougie' Douglas Date: Thu, 15 Aug 2024 19:28:57 -0700 Subject: [PATCH 2/3] adds context on 30 days --- src/popup/pages/profile.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/popup/pages/profile.tsx b/src/popup/pages/profile.tsx index 50b880b2..00b8c884 100644 --- a/src/popup/pages/profile.tsx +++ b/src/popup/pages/profile.tsx @@ -189,7 +189,7 @@ export const Profile = ({ username }: { username: string }) => {
-

PR Count

+

PR Count (30 days)

{userPR?.meta.itemCount}

@@ -203,7 +203,7 @@ export const Profile = ({ username }: { username: string }) => {
-

Contributed Repos

+

Contributed Repos (30 days)

{countUniqueRepos(userPR)}

From 717c60d57534b58462cec5b51849339d563adebf Mon Sep 17 00:00:00 2001 From: Brian Douglas Date: Fri, 16 Aug 2024 07:21:57 -0700 Subject: [PATCH 3/3] Update profile.tsx Co-authored-by: Nick Taylor --- src/popup/pages/profile.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/popup/pages/profile.tsx b/src/popup/pages/profile.tsx index 00b8c884..524ebf4e 100644 --- a/src/popup/pages/profile.tsx +++ b/src/popup/pages/profile.tsx @@ -197,7 +197,7 @@ export const Profile = ({ username }: { username: string }) => {

OSCR

- {user?.bio && ( + {user && (

{Math.ceil(user.oscr)}

)}