Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-155
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-155
2021-155
Commits
15030d1b
Commit
15030d1b
authored
Jul 29, 2021
by
Kamal Thennakoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve calculation algorithm
parent
d80e42b9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
64 deletions
+114
-64
client/components/portfolio/portfolio-generate-dialog/portfolio-generate-dialog.js
...io/portfolio-generate-dialog/portfolio-generate-dialog.js
+1
-1
client/pages/portfolio/[username].js
client/pages/portfolio/[username].js
+22
-16
client/public/images/portfolio/js-blog.jpg
client/public/images/portfolio/js-blog.jpg
+0
-0
github-scorer-cloud/package.json
github-scorer-cloud/package.json
+1
-0
github-scorer-cloud/services/common/calculateRank.js
github-scorer-cloud/services/common/calculateRank.js
+90
-47
No files found.
client/components/portfolio/portfolio-generate-dialog/portfolio-generate-dialog.js
View file @
15030d1b
...
...
@@ -19,7 +19,7 @@ export default function PortfolioGenerateDialog(props) {
const
handleChange
=
(
e
)
=>
{
console
.
log
(
e
.
target
.
value
)
setUsername
(
e
.
target
.
value
)
setUsername
(
e
.
target
.
value
.
toLowerCase
()
)
}
const
navigateToPortfolio
=
(
username
)
=>
{
console
.
log
(
'
username::
'
,
username
)
...
...
client/pages/portfolio/[username].js
View file @
15030d1b
...
...
@@ -43,6 +43,9 @@ const useStyles = makeStyles((theme) => ({
},
chipMl
:
{
marginRight
:
'
15px
'
},
para
:{
fontSize
:
'
18px
'
}
}))
...
...
@@ -66,7 +69,7 @@ function Porto({ gitInfo }) {
<
div
className
=
{
classes
.
root
}
>
<
Header
><
/Header
>
<
Container
>
<
Grid
container
spacing
=
{
3
}
>
<
Grid
container
spacing
=
{
8
}
>
{
/* ProPic and Indicators */
}
<
Grid
item
container
xs
=
{
12
}
sm
=
{
6
}
spacing
=
{
3
}
>
<
Grid
item
xs
=
{
12
}
sm
=
{
6
}
>
...
...
@@ -90,9 +93,9 @@ function Porto({ gitInfo }) {
justify
=
"
space-around
"
>
{
/* Reputation Bars */
}
<
ReputationIndicator
area
=
'
stackOveflow
'
rank
=
{{
level
:
30
,
badge
:
'
none
'
}}
><
/ReputationIndicator
>
<
ReputationIndicator
area
=
'
GitHub
'
rank
=
{
gitInfo
.
summary
.
stats
.
rank
}
><
/ReputationIndicator
>
<
ReputationIndicator
area
=
'
stackOveflow
'
rank
=
{{
level
:
30
,
badge
:
'
none
'
}}
><
/ReputationIndicator
>
<
ReputationIndicator
area
=
'
Knowledge
'
rank
=
{{
level
:
1
,
badge
:
'
none
'
}}
><
/ReputationIndicator
>
<
ReputationIndicator
area
=
'
Coding
'
rank
=
{
gitInfo
.
summary
.
stats
.
rank
}
><
/ReputationIndicator
>
<
ReputationIndicator
area
=
'
Academics
'
rank
=
{{
level
:
1
,
badge
:
'
none
'
}}
><
/ReputationIndicator
>
{
/* Reputation Bars End */
}
<
/Grid
>
...
...
@@ -111,7 +114,7 @@ function Porto({ gitInfo }) {
/>
<
/Card
>
<
/Paper
>
<
Typography
>
Top
Language
<
/Typography
>
<
Typography
>
Top
Framework
<
/Typography
>
<
/Grid
>
<
Grid
item
...
...
@@ -127,7 +130,7 @@ function Porto({ gitInfo }) {
<
Rating
name
=
"
read-only
"
value
=
{
3
}
readOnly
/>
<
/Box
>
<
Typography
>
Java
Script
<
/Typography
>
<
Typography
>
React
.
js
<
/Typography
>
<
Typography
>
Experiance
:
3
yrs
<
/Typography
>
<
/Grid
>
...
...
@@ -166,8 +169,8 @@ function Porto({ gitInfo }) {
<
/Grid
>
{
/* End Fav Language 2 Blocks */
}
{
/* Chips (Languages) */
}
<
Grid
item
container
xs
=
{
12
}
spacing
=
{
2
}
>
<
Chip
<
Grid
item
container
xs
=
{
12
}
spacing
=
{
1
}
>
{
/*
<Chip
className={classes.chipMl}
label="JavaScript"
avatar={<Avatar src="/images/portfolio/javaLogo.png" />}
...
...
@@ -178,20 +181,21 @@ function Porto({ gitInfo }) {
label="JavaScript"
avatar={<Avatar src="/images/portfolio/javaLogo.png" />}
variant="outlined"
/>
/> */
}
<
Typography
className
=
{
classes
.
para
}
>
{
gitInfo
.
summary
.
userBio
.
bio
}
<
/Typography
>
<
/Grid
>
{
/* End Chips (Languages) */
}
<
/Grid
>
{
/* Github Stats */
}
<
Grid
container
item
xs
=
{
12
}
>
<
Grid
item
xs
=
{
4
}
>
<
FavLanguageCard
><
/FavLanguageCard
>
<
FavLanguageCard
languages
=
{
gitInfo
.
topLang
}
><
/FavLanguageCard
>
<
/Grid
>
<
Grid
item
xs
=
{
4
}
>
<
TimeLanguageCard
><
/TimeLanguageCard
>
<
/Grid
>
<
Grid
item
xs
=
{
4
}
>
<
GitSummaryCard
><
/GitSummaryCard
>
<
GitSummaryCard
info
=
{
gitInfo
.
summary
}
><
/GitSummaryCard
>
<
/Grid
>
<
/Grid
>
{
/* End Github Stats */
}
...
...
@@ -205,7 +209,7 @@ function Porto({ gitInfo }) {
direction
=
"
row
"
>
<
Grid
item
xs
=
{
11
}
>
<
Storyline
><
/Storyline
>
<
Storyline
userData
=
{
gitInfo
.
summary
.
userBio
.
created_at
}
><
/Storyline
>
<
/Grid
>
<
/Grid
>
{
/* End Story Line */
}
...
...
@@ -213,14 +217,15 @@ function Porto({ gitInfo }) {
<
BlogCard
><
/BlogCard
>
<
/Grid
>
<
Grid
item
xs
=
{
6
}
sm
=
{
3
}
>
<
Paper
className
=
{
classes
.
paper2
}
>
xs
=
6
sm
=
3
<
/Paper
>
<
BlogCard
><
/BlogCard
>
<
/Grid
>
<
Grid
item
xs
=
{
6
}
sm
=
{
3
}
>
<
Paper
className
=
{
classes
.
paper2
}
>
xs
=
6
sm
=
3
<
/Paper
>
<
BlogCard
><
/BlogCard
>
<
/Grid
>
<
Grid
item
xs
=
{
6
}
sm
=
{
3
}
>
<
Paper
className
=
{
classes
.
paper2
}
>
xs
=
6
sm
=
3
<
/Paper
>
<
BlogCard
><
/BlogCard
>
<
/Grid
>
<
Grid
item
xs
=
{
12
}
>
<
Paper
className
=
{
classes
.
paper2
}
>
xs
=
12
<
/Paper
>
<
/Grid
>
...
...
@@ -247,6 +252,7 @@ export async function getStaticPaths() {
export
async
function
getStaticProps
({
params
})
{
// get gitInfo data based on slug
const
gitInfo
=
await
getGithubInfo
(
params
.
username
)
//response data [ single gitInfo] recived with array brackets
console
.
log
(
'
username cased:
'
,
params
.
username
.
toLowerCase
())
const
gitInfo
=
await
getGithubInfo
(
params
.
username
.
toLowerCase
())
//response data [ single gitInfo] recived with array brackets
return
{
props
:
{
gitInfo
}
}
}
client/public/images/portfolio/js-blog.jpg
0 → 100644
View file @
15030d1b
20.7 KB
github-scorer-cloud/package.json
View file @
15030d1b
...
...
@@ -27,6 +27,7 @@
"dotenv"
:
"^8.2.0"
,
"emoji-name-map"
:
"^1.2.8"
,
"github-username-regex"
:
"^1.0.0"
,
"moment"
:
"^2.29.1"
,
"prettier"
:
"^2.1.2"
,
"word-wrap"
:
"^1.2.3"
}
...
...
github-scorer-cloud/services/common/calculateRank.js
View file @
15030d1b
// https://stackoverflow.com/a/5263759/10629172
const
moment
=
require
(
"
moment
"
);
function
normalcdf
(
mean
,
sigma
,
to
)
{
var
z
=
(
to
-
mean
)
/
Math
.
sqrt
(
2
*
sigma
*
sigma
);
var
t
=
1
/
(
1
+
0.3275911
*
Math
.
abs
(
z
));
...
...
@@ -21,73 +22,115 @@ function calculateRank({
totalCommits
,
contributions
,
followers
,
pr
s
,
totalPR
s
,
issues
,
stargazers
,
createdAt
})
{
const
COMMITS_
OFFSE
T
=
1.65
;
const
CONTRIBS_
OFFSE
T
=
1.65
;
const
ISSUES_
OFFSE
T
=
1
;
const
STARS_
OFFSE
T
=
0.75
;
const
PRS_
OFFSE
T
=
0.5
;
const
FOLLOWERS_
OFFSE
T
=
0.45
;
const
REPO_
OFFSE
T
=
1
;
const
COMMITS_
WEIGH
T
=
1.65
;
const
CONTRIBS_
WEIGH
T
=
1.65
;
const
ISSUES_
WEIGH
T
=
1
;
const
STARS_
WEIGH
T
=
0.75
;
const
PRS_
WEIGH
T
=
0.5
;
const
FOLLOWERS_
WEIGH
T
=
0.45
;
const
REPO_
WEIGH
T
=
1
;
const
ALL_
OFFSE
TS
=
CONTRIBS_
OFFSE
T
+
ISSUES_
OFFSE
T
+
STARS_
OFFSE
T
+
PRS_
OFFSE
T
+
FOLLOWERS_
OFFSE
T
+
REPO_
OFFSE
T
;
const
ALL_
WEIGH
TS
=
CONTRIBS_
WEIGH
T
+
ISSUES_
WEIGH
T
+
STARS_
WEIGH
T
+
PRS_
WEIGH
T
+
FOLLOWERS_
WEIGH
T
+
REPO_
WEIGH
T
;
const
RANK_S_VALUE
=
1
;
const
RANK_DOUBLE_A_VALUE
=
25
;
const
RANK_A2_VALUE
=
45
;
const
RANK_A3_VALUE
=
60
;
const
RANK_B_VALUE
=
100
;
const
LVL_GURU
=
1
;
const
LVL_PROFESSIONAL
=
25
;
const
LVL_ADVANCED
=
45
;
const
LVL_INTERMEDIATE
=
55
;
const
LVL_BEGINNER
=
80
;
const
LVL_NEWBIE
=
100
const
TOTAL_VALUES
=
RANK_S_VALUE
+
RANK_A2_VALUE
+
RANK_A3_VALUE
+
RANK_B_VALUE
;
LVL_GURU
+
LVL_ADVANCED
+
LVL_INTERMEDIATE
+
LVL_NEWBIE
+
5
;
// prettier-ignore
const
score
=
(
totalCommits
*
COMMITS_OFFSET
+
contributions
*
CONTRIBS_OFFSET
+
issues
*
ISSUES_OFFSET
+
stargazers
*
STARS_OFFSET
+
prs
*
PRS_OFFSET
+
followers
*
FOLLOWERS_OFFSET
+
totalRepos
*
REPO_OFFSET
const
rewardPoints
=
(
totalCommits
*
COMMITS_WEIGHT
+
contributions
*
CONTRIBS_WEIGHT
+
issues
*
ISSUES_WEIGHT
+
stargazers
*
STARS_WEIGHT
+
totalPRs
*
PRS_WEIGHT
+
followers
*
FOLLOWERS_WEIGHT
+
totalRepos
*
REPO_WEIGHT
)
/
100
;
const
todayDate
=
new
moment
(
Date
.
now
());
const
joinedDate
=
new
moment
(
createdAt
);
const
profileAge
=
moment
.
duration
(
todayDate
.
diff
(
joinedDate
)).
asDays
();
console
.
log
(
'
day duration
'
,
moment
.
duration
(
todayDate
.
diff
(
joinedDate
)).
asDays
());
let
penaltyPoints
=
0
;
// penalty calculation
if
(
totalCommits
<
1000
){
penaltyPoints
=
(
totalCommits
==
0
?(
-
1000
):(
-
1000
/
totalCommits
))
+
penaltyPoints
;
console
.
log
(
'
Commit-Penalty:
'
,
penaltyPoints
);
}
if
(
totalPRs
<
15
){
penaltyPoints
=
(
totalPRs
==
0
?(
-
150
):
(
-
1500
/
(
totalPRs
*
100
)))
+
penaltyPoints
;
console
.
log
(
'
PRs-Penalty:
'
,
penaltyPoints
);
}
if
(
profileAge
<
365
){
penaltyPoints
=
(
profileAge
==
0
?(
-
365
):(
-
365
/
profileAge
))
+
penaltyPoints
;
console
.
log
(
'
Age-Penalty:
'
,
penaltyPoints
);
}
console
.
log
(
'
total-Rewards
'
,
rewardPoints
);
console
.
log
(
'
total-Penalty
'
,
penaltyPoints
);
const
totalScore
=
rewardPoints
+
penaltyPoints
;
const
normalizedScore
=
normalcdf
(
totalScore
,
TOTAL_VALUES
,
ALL_WEIGHTS
)
*
100
;
console
.
log
(
'
avg is:
'
,
totalScore
);
console
.
log
(
'
sigma is:
'
,
TOTAL_VALUES
);
console
.
log
(
'
to is:
'
,
ALL_WEIGHTS
);
console
.
log
(
'
===================
'
);
const
normalizedScore
=
normalcdf
(
score
,
TOTAL_VALUES
,
ALL_OFFSETS
)
*
100
;
let
level
=
""
;
let
level
=
0
;
let
rank
=
''
;
if
(
normalizedScore
<
RANK_S_VALUE
)
{
level
=
"
95%+
"
;
if
(
normalizedScore
<
LVL_GURU
)
{
level
=
95
;
rank
=
'
Guru
'
}
if
(
normalizedScore
>=
RANK_S_VALUE
&&
normalizedScore
<
RANK_DOUBLE_A_VALUE
normalizedScore
>=
LVL_GURU
&&
normalizedScore
<
LVL_PROFESSIONAL
)
{
level
=
"
80%+
"
;
level
=
80
;
rank
=
'
Professional
'
}
if
(
normalizedScore
>=
RANK_DOUBLE_A_VALUE
&&
normalizedScore
<
RANK_A2_VALUE
normalizedScore
>=
LVL_PROFESSIONAL
&&
normalizedScore
<
LVL_ADVANCED
)
{
level
=
"
70%+
"
;
level
=
70
;
rank
=
'
Advanced
'
}
if
(
normalizedScore
>=
LVL_ADVANCED
&&
normalizedScore
<
LVL_INTERMEDIATE
)
{
level
=
50
;
rank
=
'
Intermediate
'
}
if
(
normalizedScore
>=
RANK_A2_VALUE
&&
normalizedScore
<
RANK_A3_VALUE
)
{
level
=
"
50%+
"
;
if
(
normalizedScore
>=
LVL_INTERMEDIATE
&&
normalizedScore
<
LVL_BEGINNER
)
{
level
=
30
;
rank
=
'
Beginner
'
}
if
(
normalizedScore
>=
RANK_A3_VALUE
&&
normalizedScore
<
RANK_B_VALUE
)
{
level
=
"
30%+
"
;
if
(
normalizedScore
>=
LVL_BEGINNER
&&
normalizedScore
<
LVL_NEWBIE
){
level
=
10
;
rank
=
'
Newbie
'
}
return
{
level
,
score
:
normalizedScore
};
return
{
level
,
score
:
normalizedScore
,
badge
:
rank
,
points
:
totalScore
};
}
module
.
exports
=
calculateRank
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment