Skip to content

Commit

Permalink
feat(prs): stacked bar (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Aug 18, 2024
1 parent 9212d07 commit efb79ff
Showing 1 changed file with 55 additions and 23 deletions.
78 changes: 55 additions & 23 deletions notebook/dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,18 @@
" \"archived\": repo.archived,\n",
" \"fork\": repo.fork,\n",
" \"forks\": repo.forks_count,\n",
" \"issues\": len(open_issues),\n",
" \"issues\": open_issues,\n",
" \"topics\": repo.get_topics(),\n",
" \"languages\": repo.get_languages(),\n",
" \"license\": license_name,\n",
" \"prs\": len(open_prs),\n",
" \"prs\": open_prs,\n",
" \"created_at\": repo.created_at,\n",
" \"updated_at\": repo.updated_at,\n",
" \"coverage\": coverage,\n",
" \"readthedocs\": readthedocs_project,\n",
" \"has_readthedocs\": readthedocs_project is not None,\n",
" \"has_readme\": readme_file is not None,\n",
" \"_repo\": repo,\n",
" })\n",
"\n",
"df = pd.DataFrame(repo_data)\n",
Expand All @@ -186,10 +187,11 @@
"print(f'Total Repositories: {len(repo_data)}')\n",
"print(f'Archived Repositories: {df[\"archived\"].sum()}')\n",
"print(f'Forked Repositories: {df[\"fork\"].sum()}')\n",
"print(f'Total Open Issues: {df[\"issues\"].sum()}')\n",
"print(f'Total Open PRs: {df[\"prs\"].sum()}')\n",
"print(f'Open issues in active repositories: {df_repos[\"issues\"].sum()}')\n",
"print(f'Open PRs in active repositories: {df_repos[\"prs\"].sum()}')"
"\n",
"print(f'Total Open Issues: {df[\"issues\"].apply(len).sum()}')\n",
"print(f'Total Open PRs: {df[\"prs\"].apply(len).sum()}')\n",
"print(f'Open issues in active repositories: {df_repos[\"issues\"].apply(len).sum()}')\n",
"print(f'Open PRs in active repositories: {df_repos[\"prs\"].apply(len).sum()}')"
],
"id": "initial_id",
"outputs": [],
Expand Down Expand Up @@ -293,17 +295,26 @@
},
"source": [
"# Open Issues\n",
"\n",
"# Calculate the count of issues for each repository\n",
"df_repos.loc[:, 'issue_count'] = df_repos['issues'].apply(len)\n",
"\n",
"# Sort by issue count in descending order\n",
"df_issues = df_repos.sort_values(\n",
" by='issues',\n",
" by='issue_count',\n",
" ascending=False,\n",
")\n",
"df_issues['log_issues'] = np.log1p(df_issues['issues'])\n",
"\n",
"# Calculate the log of issue count\n",
"df_issues.loc[:, 'log_issues'] = np.log1p(df_issues['issue_count'])\n",
"\n",
"# Visualize data using a bar chart\n",
"fig = px.bar(\n",
" df_issues,\n",
" x='repo',\n",
" y='log_issues',\n",
" title='Open Issues',\n",
" text='issues',\n",
" text='issue_count',\n",
")\n",
"fig.update_traces(\n",
" texttemplate='%{text}',\n",
Expand Down Expand Up @@ -334,25 +345,46 @@
},
"source": [
"# Open PRs\n",
"df_prs = df_repos.sort_values(\n",
" by='prs',\n",
" ascending=False,\n",
")\n",
"df_prs['log_prs'] = np.log1p(df_prs['prs'])\n",
"pr_data = []\n",
"for repo in df_repos.to_dict('records'):\n",
" draft_prs = 0\n",
" non_draft_prs = 0\n",
" dependabot_prs = 0\n",
"\n",
" for pr in repo['prs']:\n",
" pr_details = repo['_repo'].get_pull(pr.number)\n",
" if pr_details.user.login == 'dependabot[bot]' or pr_details.user.login == 'renovate[bot]':\n",
" dependabot_prs += 1\n",
" elif pr_details.draft:\n",
" draft_prs += 1\n",
" else:\n",
" non_draft_prs += 1\n",
"\n",
" pr_data.append({\n",
" \"repo\": repo['repo'],\n",
" \"Draft\": draft_prs,\n",
" \"Ready for review\": non_draft_prs,\n",
" \"Dependency\": dependabot_prs,\n",
" })\n",
"\n",
"df_prs = pd.DataFrame(pr_data)\n",
"df_prs['total_prs'] = df_prs[['Draft', 'Ready for review', 'Dependency']].sum(axis=1)\n",
"\n",
"# Sort by total PRs in descending order\n",
"df_prs = df_prs.sort_values(by='total_prs', ascending=False)\n",
"\n",
"# Visualize data using a stacked bar chart\n",
"fig = px.bar(\n",
" df_prs,\n",
" x='repo',\n",
" y='log_prs',\n",
" title='Open PRs',\n",
" text='prs',\n",
")\n",
"fig.update_traces(\n",
" texttemplate='%{text}',\n",
" textposition='inside',\n",
" y=['Draft', 'Ready for review', 'Dependency'],\n",
" title='Open Pull Requests',\n",
" labels={'value': 'Count', 'variable': 'PR Type'},\n",
" barmode='stack'\n",
")\n",
"fig.update_layout(\n",
" yaxis_title=None,\n",
" yaxis_showticklabels=False,\n",
" yaxis_title='Count of PRs',\n",
" xaxis_title='Repository',\n",
")\n",
"fig.show()"
],
Expand Down

0 comments on commit efb79ff

Please sign in to comment.