diff --git a/notebook/dashboard.ipynb b/notebook/dashboard.ipynb index e0d2280e..46696b11 100644 --- a/notebook/dashboard.ipynb +++ b/notebook/dashboard.ipynb @@ -109,7 +109,6 @@ "\n", "# set the default plotly template\n", "pio.templates.default = \"plotly_dark\"\n", - "pio.renderers.default = 'notebook'\n", "\n", "# Fetch repository data\n", "org_name = \"LizardByte\"\n", @@ -201,7 +200,6 @@ "outputs": [], "source": [ "# Initial data frames\n", - "\n", "df = pd.DataFrame(repo_data)\n", "df_repos = df[\n", " (~df['archived']) &\n", @@ -406,25 +404,20 @@ "# PR Data\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", - " })" + " pr_data.append({\n", + " \"repo\": repo['repo'],\n", + " \"number\": pr_details.number,\n", + " \"title\": pr_details.title,\n", + " \"author\": pr_details.user.login,\n", + " \"labels\": [label.name for label in pr_details.labels],\n", + " \"assignees\": [assignee.login for assignee in pr_details.assignees],\n", + " \"ready\": not pr_details.draft,\n", + " \"created_at\": pr_details.created_at,\n", + " \"last_activity\": pr_details.updated_at,\n", + " \"status\": \"Draft\" if pr_details.draft else \"Ready\",\n", + " })" ] }, { @@ -434,24 +427,49 @@ "metadata": {}, "outputs": [], "source": [ - "# Open PRs\n", - "df_prs = pd.DataFrame(pr_data)\n", - "df_prs['total_prs'] = df_prs[['Draft', 'Ready for review', 'Dependency']].sum(axis=1)\n", - "df_prs = df_prs.sort_values(by='total_prs', ascending=False)\n", + "# Create DataFrame for PR details\n", + "df_pr_details = pd.DataFrame(pr_data)\n", + "\n", + "# Group by repository and status to get the count of PRs\n", + "df_pr_counts = df_pr_details.groupby(['repo', 'status']).size().reset_index(name='pr_count')\n", + "\n", + "# Sort repositories by total PR count\n", + "df_pr_counts['total_prs'] = df_pr_counts.groupby('repo')['pr_count'].transform('sum')\n", + "df_pr_counts = df_pr_counts.sort_values(by='total_prs', ascending=False)\n", + "\n", + "# Create PR Table\n", + "fig_table = go.Figure(data=[go.Table(\n", + " header=dict(values=list(df_pr_details.columns),\n", + " align='left'),\n", + " cells=dict(values=[df_pr_details[col] for col in df_pr_details.columns],\n", + " align='left'))\n", + "])\n", + "fig_table.update_layout(\n", + " title='Pull Request Details',\n", + " height=800,\n", + ")\n", + "fig_table.show()\n", "\n", - "fig = px.bar(\n", - " df_prs,\n", + "# Create Stacked Bar Chart\n", + "fig_bar = px.bar(\n", + " df_pr_counts,\n", " x='repo',\n", - " y=['Draft', 'Ready for review', 'Dependency'],\n", + " y='pr_count',\n", + " color='status',\n", " title='Open Pull Requests',\n", - " labels={'value': 'Count', 'variable': 'PR Type'},\n", - " barmode='stack'\n", + " labels={'pr_count': 'Count of PRs', 'repo': 'Repository', 'status': 'PR Status'},\n", + " text='pr_count',\n", + " category_orders={'repo': df_pr_counts['repo'].tolist()},\n", ")\n", - "fig.update_layout(\n", - " yaxis_title='Count of PRs',\n", + "fig_bar.update_layout(\n", + " yaxis_title='Open PRs',\n", " xaxis_title='Repository',\n", ")\n", - "fig.show()" + "fig_bar.update_traces(\n", + " texttemplate=text_template,\n", + " textposition='inside',\n", + ")\n", + "fig_bar.show()" ] }, {