Skip to content

Commit

Permalink
feat(pr): add table filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Aug 21, 2024
1 parent ef2c72c commit 8f2a55a
Showing 1 changed file with 249 additions and 5 deletions.
254 changes: 249 additions & 5 deletions notebook/dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,6 @@
" 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",
"# Create Stacked Bar Chart\n",
"fig_bar = px.bar(\n",
Expand All @@ -461,6 +456,253 @@
" text='pr_count',\n",
" category_orders={'repo': df_pr_counts['repo'].tolist()},\n",
")\n",
"\n",
"# common filter button properties\n",
"y_button_position = 1.1\n",
"x_button_factor = 0.15\n",
"bg_color = \"lightgray\"\n",
"font = {\"color\": \"black\"}\n",
"\n",
"# Add common dropdown filters for repository, status, author, labels, and assignees\n",
"updatemenus = [\n",
" {\n",
" \"buttons\": [\n",
" {\n",
" \"label\": \"All Repos\",\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts['repo']],\n",
" \"y\": [df_pr_counts['pr_count']],\n",
" \"text\": [df_pr_counts['pr_count']],\n",
" },\n",
" ],\n",
" },\n",
" ] + [\n",
" {\n",
" \"label\": repo,\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[df_pr_details['repo'] == repo][col]\n",
" for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts[df_pr_counts['repo'] == repo]['repo']],\n",
" \"y\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" \"text\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" },\n",
" ],\n",
" } for repo in df_pr_details['repo'].unique()\n",
" ],\n",
" \"direction\": \"down\",\n",
" \"showactive\": True,\n",
" \"x\": x_button_factor,\n",
" \"xanchor\": \"left\",\n",
" \"y\": y_button_position,\n",
" \"yanchor\": \"top\",\n",
" \"bgcolor\": bg_color,\n",
" \"font\": font,\n",
" },\n",
" {\n",
" \"buttons\": [\n",
" {\n",
" \"label\": \"All Authors\",\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts['repo']],\n",
" \"y\": [df_pr_counts['pr_count']],\n",
" \"text\": [df_pr_counts['pr_count']],\n",
" },\n",
" ],\n",
" },\n",
" ] + [\n",
" {\n",
" \"label\": author,\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[df_pr_details['author'] == author][col]\n",
" for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts[df_pr_counts['repo'] == repo]['repo']],\n",
" \"y\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" \"text\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" },\n",
" ],\n",
" } for author in df_pr_details['author'].unique()\n",
" ],\n",
" \"direction\": \"down\",\n",
" \"showactive\": True,\n",
" \"x\": x_button_factor * 2,\n",
" \"xanchor\": \"left\",\n",
" \"y\": y_button_position,\n",
" \"yanchor\": \"top\",\n",
" \"bgcolor\": bg_color,\n",
" \"font\": font,\n",
" },\n",
" {\n",
" \"buttons\": [\n",
" {\n",
" \"label\": \"All Labels\",\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts['repo']],\n",
" \"y\": [df_pr_counts['pr_count']],\n",
" \"text\": [df_pr_counts['pr_count']],\n",
" },\n",
" ],\n",
" },\n",
" ] + [\n",
" {\n",
" \"label\": label,\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[df_pr_details['labels'].apply(\n",
" lambda x: label in x)][col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts[df_pr_counts['repo'] == repo]['repo']],\n",
" \"y\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" \"text\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" },\n",
" ],\n",
" } for label in set(label for labels in df_pr_details['labels'] for label in labels)\n",
" ],\n",
" \"direction\": \"down\",\n",
" \"showactive\": True,\n",
" \"x\": x_button_factor * 3,\n",
" \"xanchor\": \"left\",\n",
" \"y\": y_button_position,\n",
" \"yanchor\": \"top\",\n",
" \"bgcolor\": bg_color,\n",
" \"font\": font,\n",
" },\n",
" {\n",
" \"buttons\": [\n",
" {\n",
" \"label\": \"All Assignees\",\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts['repo']],\n",
" \"y\": [df_pr_counts['pr_count']],\n",
" \"text\": [df_pr_counts['pr_count']],\n",
" },\n",
" ],\n",
" },\n",
" ] + [\n",
" {\n",
" \"label\": assignee,\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[df_pr_details['assignees'].apply(\n",
" lambda x: assignee in x)][col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts[df_pr_counts['repo'] == repo]['repo']],\n",
" \"y\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" \"text\": [df_pr_counts[df_pr_counts['repo'] == repo]['pr_count']],\n",
" },\n",
" ],\n",
" } for assignee in set(assignee for assignees in df_pr_details['assignees'] for assignee in assignees)\n",
" ],\n",
" \"direction\": \"down\",\n",
" \"showactive\": True,\n",
" \"x\": x_button_factor * 4,\n",
" \"xanchor\": \"left\",\n",
" \"y\": y_button_position,\n",
" \"yanchor\": \"top\",\n",
" \"bgcolor\": bg_color,\n",
" \"font\": font,\n",
" },\n",
" {\n",
" \"buttons\": [\n",
" {\n",
" \"label\": \"All Statuses\",\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[col] for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts['repo']],\n",
" \"y\": [df_pr_counts['pr_count']],\n",
" \"text\": [df_pr_counts['pr_count']],\n",
" },\n",
" ],\n",
" },\n",
" ] + [\n",
" {\n",
" \"label\": status,\n",
" \"method\": \"update\",\n",
" \"args\": [\n",
" {\n",
" \"cells\": {\n",
" \"values\": [df_pr_details[df_pr_details['status'] == status][col]\n",
" for col in df_pr_details.columns],\n",
" },\n",
" },\n",
" {\n",
" \"x\": [df_pr_counts[df_pr_counts['status'] == status]['repo']],\n",
" \"y\": [df_pr_counts[df_pr_counts['status'] == status]['pr_count']],\n",
" \"text\": [df_pr_counts[df_pr_counts['status'] == status]['pr_count']],\n",
" },\n",
" ],\n",
" } for status in df_pr_details['status'].unique()\n",
" ],\n",
" \"direction\": \"down\",\n",
" \"showactive\": True,\n",
" \"x\": x_button_factor * 5,\n",
" \"xanchor\": \"left\",\n",
" \"y\": y_button_position,\n",
" \"yanchor\": \"top\",\n",
" \"bgcolor\": bg_color,\n",
" \"font\": font,\n",
" }\n",
"]\n",
"\n",
"fig_table.update_layout(\n",
" title='Pull Request Details',\n",
" height=800,\n",
" updatemenus=updatemenus,\n",
")\n",
"\n",
"fig_bar.update_layout(\n",
" yaxis_title='Open PRs',\n",
" xaxis_title='Repository',\n",
Expand All @@ -469,6 +711,8 @@
" texttemplate=text_template,\n",
" textposition='inside',\n",
")\n",
"\n",
"fig_table.show()\n",
"fig_bar.show()"
]
},
Expand Down

0 comments on commit 8f2a55a

Please sign in to comment.