fix
Browse files
app.py
CHANGED
|
@@ -31,11 +31,8 @@ LEADERBOARD_COLUMNS = [
|
|
| 31 |
("Organization", "string"),
|
| 32 |
("GitHub Name", "string"),
|
| 33 |
("Total PRs", "number"),
|
| 34 |
-
("Merged", "number"),
|
| 35 |
-
("Open", "number"),
|
| 36 |
-
("Closed (Not Merged)", "number"),
|
| 37 |
("Acceptance Rate (%)", "number"),
|
| 38 |
-
("Repositories", "number"),
|
| 39 |
("First Contribution", "string"),
|
| 40 |
("Last Updated", "string")
|
| 41 |
]
|
|
@@ -268,8 +265,6 @@ def calculate_pr_stats(prs):
|
|
| 268 |
"""
|
| 269 |
total_prs = len(prs)
|
| 270 |
merged = 0
|
| 271 |
-
open_count = 0
|
| 272 |
-
closed_not_merged = 0
|
| 273 |
repos = set()
|
| 274 |
prs_by_repo = defaultdict(int)
|
| 275 |
first_contribution = None
|
|
@@ -293,24 +288,17 @@ def calculate_pr_stats(prs):
|
|
| 293 |
|
| 294 |
# Track PR status
|
| 295 |
state = pr.get('state')
|
| 296 |
-
if state == '
|
| 297 |
-
open_count += 1
|
| 298 |
-
elif state == 'closed':
|
| 299 |
pull_request = pr.get('pull_request', {})
|
| 300 |
if pull_request.get('merged_at'):
|
| 301 |
merged += 1
|
| 302 |
-
else:
|
| 303 |
-
closed_not_merged += 1
|
| 304 |
|
| 305 |
acceptance_rate = (merged / total_prs * 100) if total_prs > 0 else 0
|
| 306 |
|
| 307 |
return {
|
| 308 |
'total_prs': total_prs,
|
| 309 |
'merged': merged,
|
| 310 |
-
'open': open_count,
|
| 311 |
-
'closed_not_merged': closed_not_merged,
|
| 312 |
'acceptance_rate': round(acceptance_rate, 2),
|
| 313 |
-
'repo_count': len(repos),
|
| 314 |
'first_contribution': first_contribution or 'N/A',
|
| 315 |
'last_contribution': last_contribution or 'N/A',
|
| 316 |
'prs_by_repo': dict(prs_by_repo)
|
|
@@ -570,10 +558,7 @@ def get_leaderboard_dataframe():
|
|
| 570 |
github_name,
|
| 571 |
data.get('total_prs', 0),
|
| 572 |
data.get('merged', 0),
|
| 573 |
-
data.get('open', 0),
|
| 574 |
-
data.get('closed_not_merged', 0),
|
| 575 |
data.get('acceptance_rate', 0.0),
|
| 576 |
-
data.get('repo_count', 0),
|
| 577 |
normalize_date_format(data.get('first_contribution', 'N/A')),
|
| 578 |
normalize_date_format(data.get('last_updated', 'N/A'))
|
| 579 |
])
|
|
@@ -583,15 +568,14 @@ def get_leaderboard_dataframe():
|
|
| 583 |
df = pd.DataFrame(rows, columns=column_names)
|
| 584 |
|
| 585 |
# Ensure numeric types
|
| 586 |
-
numeric_cols = ["Total PRs", "Merged
|
| 587 |
-
"Acceptance Rate (%)", "Repositories"]
|
| 588 |
for col in numeric_cols:
|
| 589 |
if col in df.columns:
|
| 590 |
df[col] = pd.to_numeric(df[col], errors='coerce').fillna(0)
|
| 591 |
|
| 592 |
-
# Sort by
|
| 593 |
-
if "
|
| 594 |
-
df = df.sort_values(by="
|
| 595 |
|
| 596 |
return df
|
| 597 |
|
|
|
|
| 31 |
("Organization", "string"),
|
| 32 |
("GitHub Name", "string"),
|
| 33 |
("Total PRs", "number"),
|
| 34 |
+
("Merged PRs", "number"),
|
|
|
|
|
|
|
| 35 |
("Acceptance Rate (%)", "number"),
|
|
|
|
| 36 |
("First Contribution", "string"),
|
| 37 |
("Last Updated", "string")
|
| 38 |
]
|
|
|
|
| 265 |
"""
|
| 266 |
total_prs = len(prs)
|
| 267 |
merged = 0
|
|
|
|
|
|
|
| 268 |
repos = set()
|
| 269 |
prs_by_repo = defaultdict(int)
|
| 270 |
first_contribution = None
|
|
|
|
| 288 |
|
| 289 |
# Track PR status
|
| 290 |
state = pr.get('state')
|
| 291 |
+
if state == 'closed':
|
|
|
|
|
|
|
| 292 |
pull_request = pr.get('pull_request', {})
|
| 293 |
if pull_request.get('merged_at'):
|
| 294 |
merged += 1
|
|
|
|
|
|
|
| 295 |
|
| 296 |
acceptance_rate = (merged / total_prs * 100) if total_prs > 0 else 0
|
| 297 |
|
| 298 |
return {
|
| 299 |
'total_prs': total_prs,
|
| 300 |
'merged': merged,
|
|
|
|
|
|
|
| 301 |
'acceptance_rate': round(acceptance_rate, 2),
|
|
|
|
| 302 |
'first_contribution': first_contribution or 'N/A',
|
| 303 |
'last_contribution': last_contribution or 'N/A',
|
| 304 |
'prs_by_repo': dict(prs_by_repo)
|
|
|
|
| 558 |
github_name,
|
| 559 |
data.get('total_prs', 0),
|
| 560 |
data.get('merged', 0),
|
|
|
|
|
|
|
| 561 |
data.get('acceptance_rate', 0.0),
|
|
|
|
| 562 |
normalize_date_format(data.get('first_contribution', 'N/A')),
|
| 563 |
normalize_date_format(data.get('last_updated', 'N/A'))
|
| 564 |
])
|
|
|
|
| 568 |
df = pd.DataFrame(rows, columns=column_names)
|
| 569 |
|
| 570 |
# Ensure numeric types
|
| 571 |
+
numeric_cols = ["Total PRs", "Merged PRs", "Acceptance Rate (%)"]
|
|
|
|
| 572 |
for col in numeric_cols:
|
| 573 |
if col in df.columns:
|
| 574 |
df[col] = pd.to_numeric(df[col], errors='coerce').fillna(0)
|
| 575 |
|
| 576 |
+
# Sort by Acceptance Rate (%) descending
|
| 577 |
+
if "Acceptance Rate (%)" in df.columns and not df.empty:
|
| 578 |
+
df = df.sort_values(by="Acceptance Rate (%)", ascending=False).reset_index(drop=True)
|
| 579 |
|
| 580 |
return df
|
| 581 |
|