Skip to content

Commit 4e06f23

Browse files
committed
Add file count per commit distribution chart
1 parent 76c3111 commit 4e06f23

File tree

2 files changed

+91
-3
lines changed

2 files changed

+91
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// List how many git commits changed one file, how mandy changed two files, ....
2+
3+
MATCH (git_commit:Git:Commit)-[:CONTAINS_CHANGE]->(git_change:Git:Change)-[]->(git_file:Git:File)
4+
WITH git_commit, count(DISTINCT git_file.relativePath) AS filesPerCommit
5+
RETURN filesPerCommit, count(DISTINCT git_commit.sha) AS commitCount
6+
ORDER BY filesPerCommit ASC

jupyter/GitHistoryGeneral.ipynb

+85-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,15 @@
197197
"source": [
198198
"# Base settings for Plotly Treemap\n",
199199
"\n",
200-
"plotly_treemap_layout_base_settings = dict(\n",
200+
"plotly_main_layout_base_settings = dict(\n",
201201
" margin=dict(t=50, l=15, r=15, b=15),\n",
202202
")\n",
203+
"plotly_treemap_layout_base_settings = dict(\n",
204+
" **plotly_main_layout_base_settings\n",
205+
")\n",
206+
"plotly_bar_layout_base_settings = dict(\n",
207+
" **plotly_main_layout_base_settings\n",
208+
")\n",
203209
"plotly_treemap_figure_show_settings = dict(\n",
204210
" renderer=\"svg\" if is_command_line_execution() else None,\n",
205211
" width=1000,\n",
@@ -512,6 +518,16 @@
512518
"id": "dc0c2d06",
513519
"metadata": {},
514520
"outputs": [],
521+
"source": [
522+
"git_files_with_commit_statistics.describe()"
523+
]
524+
},
525+
{
526+
"cell_type": "code",
527+
"execution_count": null,
528+
"id": "053b448d",
529+
"metadata": {},
530+
"outputs": [],
515531
"source": [
516532
"git_files_with_commit_statistics.head(30)"
517533
]
@@ -913,6 +929,72 @@
913929
"figure.show(**plotly_treemap_figure_show_settings)"
914930
]
915931
},
932+
{
933+
"cell_type": "markdown",
934+
"id": "d8c6ccee",
935+
"metadata": {},
936+
"source": [
937+
"## Filecount per commit\n",
938+
"\n",
939+
"Shows how many commits had changed one file, how many had changed two files, and so on.\n",
940+
"The chart is limited to 30 lines for improved readability.\n",
941+
"The data preview also includes overall statistics including the number of commits that are filtered out in the chart."
942+
]
943+
},
944+
{
945+
"cell_type": "markdown",
946+
"id": "ed53b6e5",
947+
"metadata": {},
948+
"source": [
949+
"### Preview data"
950+
]
951+
},
952+
{
953+
"cell_type": "code",
954+
"execution_count": null,
955+
"id": "5526e458",
956+
"metadata": {},
957+
"outputs": [],
958+
"source": [
959+
"git_file_count_per_commit = query_cypher_to_data_frame(\"../cypher/GitLog/List_git_files_per_commit_distribution.cypher\")\n",
960+
"\n",
961+
"print(\"Sum of commits that changed more than 30 files (each) = \" + str(git_file_count_per_commit[git_file_count_per_commit['filesPerCommit'] > 30]['commitCount'].sum()))\n",
962+
"print(\"Max changed files with one commit = \" + str(git_file_count_per_commit['filesPerCommit'].max()))\n",
963+
"display(git_file_count_per_commit.describe())\n",
964+
"display(git_file_count_per_commit.head(30))"
965+
]
966+
},
967+
{
968+
"cell_type": "markdown",
969+
"id": "dcea826e",
970+
"metadata": {},
971+
"source": [
972+
"### Bar chart with the number of files per commit distribution"
973+
]
974+
},
975+
{
976+
"cell_type": "code",
977+
"execution_count": null,
978+
"id": "9e9dbc57",
979+
"metadata": {},
980+
"outputs": [],
981+
"source": [
982+
"if git_file_count_per_commit.empty:\n",
983+
" print(\"No data to plot\")\n",
984+
"else:\n",
985+
" figure = plotly_graph_objects.Figure(plotly_graph_objects.Bar(\n",
986+
" x=git_file_count_per_commit['filesPerCommit'].head(30), \n",
987+
" y=git_file_count_per_commit['commitCount'].head(30)),\n",
988+
" )\n",
989+
" figure.update_layout(\n",
990+
" **plotly_bar_layout_base_settings,\n",
991+
" title='Changed files per commit',\n",
992+
" xaxis_title='file count',\n",
993+
" yaxis_title='commit count'\n",
994+
" )\n",
995+
" figure.show(**plotly_treemap_figure_show_settings)"
996+
]
997+
},
916998
{
917999
"cell_type": "markdown",
9181000
"id": "14e87aff",
@@ -930,8 +1012,8 @@
9301012
"source": [
9311013
"# Query data from graph database\n",
9321014
"git_author_words_with_frequency = query_cypher_to_data_frame(\"../cypher/Overview/Words_for_git_author_Wordcloud_with_frequency.cypher\")\n",
933-
"# Debug \n",
934-
"# display(git_author_words_with_frequency.head(10))"
1015+
"\n",
1016+
"git_author_words_with_frequency.sort_values(by='frequency', ascending=False).reset_index(drop=True).head(10)"
9351017
]
9361018
},
9371019
{

0 commit comments

Comments
 (0)