From d1ce78b492944071476a430931cee7de7f443aaf Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:58:58 -0400 Subject: [PATCH] feat(pr): add table filters --- notebook/dashboard.ipynb | 253 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 244 insertions(+), 9 deletions(-) diff --git a/notebook/dashboard.ipynb b/notebook/dashboard.ipynb index 46696b11..d8ec04b5 100644 --- a/notebook/dashboard.ipynb +++ b/notebook/dashboard.ipynb @@ -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", @@ -461,14 +456,254 @@ " 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] 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] 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(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(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] 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", ")\n", - "fig_bar.update_traces(\n", - " texttemplate=text_template,\n", - " textposition='inside',\n", - ")\n", + "\n", + "fig_table.show()\n", "fig_bar.show()" ] },