Skip to content

Commit 4aee25e

Browse files
authored
Merge pull request #148 from O2sa/feat/scoring-alog-enhancements
Feat/scoring alog enhancements
2 parents 1f98481 + 92182d2 commit 4aee25e

51 files changed

Lines changed: 8105 additions & 693 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
GITHUB_TOKEN=your_github_token_here
2+
3+
# Redis caching (optional)
4+
# Use either redis://localhost:6379 or include password if enabled: redis://:password@localhost:6379
5+
REDIS_URL=
6+
REDIS_ENABLED=false
7+
REDIS_PASSWORD=
8+
REDIS_CACHE_NAMESPACE=devimpact:v1
9+
REDIS_CACHE_TTL_SECONDS=604800
10+
REDIS_CONNECT_TIMEOUT_MS=1500

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ dist
137137
# Vite logs files
138138
vite.config.js.timestamp-*
139139
vite.config.ts.timestamp-*
140+
server/

algorithm.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# DevImpact
2+
3+
4+
5+
6+
### 🧠 Main
7+
```
8+
compareUsers(user1, user2):
9+
10+
score1 = calculateUserScore(user1)
11+
score2 = calculateUserScore(user2)
12+
13+
IF score1 > score2:
14+
RETURN user1 as winner
15+
ELSE:
16+
RETURN user2 as winner
17+
```
18+
19+
### 🧠 User Score
20+
```
21+
calculateUserScore(user):
22+
23+
repos = getUserRepositories(user) // get the first 100 top repos
24+
prs = getUserPullRequests(user) // get the latest 100 top merged PRs that's not merged to the user repo
25+
contributions = getUserContributions(user)
26+
27+
repoScore = calculateRepoScore(repos)
28+
prScore = calculatePRScore(prs, user)
29+
contributionScore = calculateContributionScore(contributions)
30+
31+
finalScore =
32+
repoScore * 0.4 +
33+
prScore * 0.4 +
34+
contributionScore * 0.2
35+
36+
RETURN finalScore
37+
```
38+
39+
### 📦 Repository Score
40+
```
41+
calculateRepoScore(repos):
42+
43+
scores = []
44+
45+
FOR EACH repo IN repos:
46+
score =
47+
log(repo.stars + 1) * 5 +
48+
log(repo.forks + 1) * 3 +
49+
log(repo.watchers + 1) * 2
50+
51+
ADD score TO scores
52+
53+
SORT scores DESC
54+
55+
total = 0
56+
57+
FOR i FROM 0 TO length(scores)-1:
58+
IF i < 5:
59+
weight = 1 // top repos matter most
60+
ELSE:
61+
weight = 0.1 // others have low impact
62+
63+
total += scores[i] * weight
64+
65+
RETURN total
66+
```
67+
68+
69+
### 🔥 Pull Request Score
70+
```
71+
calculatePRScore(prs, username):
72+
73+
groupedPRs = groupPRsByRepository(prs)
74+
75+
totalScore = 0
76+
77+
FOR EACH repo IN groupedPRs:
78+
79+
repoPRs = groupedPRs[repo]
80+
81+
prScores = []
82+
83+
FOR EACH pr IN repoPRs:
84+
85+
// ❌ Ignore PRs to user's own repo
86+
IF pr.repoOwner == username:
87+
CONTINUE
88+
89+
// ❌ Ignore non-merged PRs
90+
IF NOT pr.isMerged:
91+
CONTINUE
92+
93+
// ✅ Base score (only for valid PRs)
94+
base =
95+
log(pr.repoStars + 1) * 2
96+
97+
// Optional: PR size factor (recommended)
98+
sizeFactor = log(pr.additions + pr.deletions + 1)
99+
100+
score = base * sizeFactor
101+
102+
ADD score TO prScores
103+
104+
// If no valid PRs, skip repo
105+
IF length(prScores) == 0:
106+
CONTINUE
107+
108+
SORT prScores DESC
109+
110+
// diminishing returns inside same repo
111+
repoTotal = 0
112+
113+
FOR i FROM 0 TO length(prScores)-1:
114+
weight = 1 / (i + 1)
115+
repoTotal += prScores[i] * weight
116+
117+
totalScore += repoTotal
118+
119+
RETURN totalScore
120+
```
121+
122+
123+
### 🌍 Contribution Score (Activity)
124+
```
125+
calculateContributionScore(contributions):
126+
127+
commits = contributions.commits // public commits
128+
prs = contributions.prs
129+
issues = contributions.issues // public issues
130+
131+
score =
132+
commits * 0.5 +
133+
prs * 2 +
134+
issues * 0.3
135+
136+
RETURN score
137+
```

0 commit comments

Comments
 (0)