Skip to content

Commit 4c20af2

Browse files
committed
fixup! Add git history commit and author statistics
1 parent f4b9976 commit 4c20af2

File tree

3 files changed

+7
-94
lines changed

3 files changed

+7
-94
lines changed

cypher/GitLog/List_git_file_directories_with_commit_statistics.cypher

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
,fileName
1717
,filePath AS fileRelativePath
1818
,split(git_commit.author, ' <')[0] AS author
19-
,split(split(git_commit.author, ' <')[1], '>')[0] AS authorEmail
20-
,git_commit.author AS authorFull
2119
,max(git_commit.sha) AS maxCommitSha
22-
,COUNT(DISTINCT git_commit.sha) AS commitCount
20+
,collect(DISTINCT git_commit.sha) AS commitHashes
2321
,date(max(git_commit.date)) AS lastCommitDate
24-
ORDER BY filePath ASCENDING, commitCount DESCENDING
2522
UNWIND pathElements AS pathElement
2623
WITH *
2724
,coalesce(nullif(split(fileRelativePath, '/' + pathElement)[0], fileRelativePath), '') AS parent
@@ -34,37 +31,29 @@ UNWIND pathElements AS pathElement
3431
,split(parent, '/')[-1] AS directoryParentName
3532
,size(split(directory, '/')) AS directoryPathLength
3633
,author
37-
,authorEmail
38-
,authorFull
39-
,count(DISTINCT fileRelativePath) AS fileCount
34+
,collect(DISTINCT fileRelativePath) AS files
4035
,max(date(fileCreatedAtTimestamp) ) AS lastCreationDate
4136
,max(date(fileLastModificationAtTimestamp)) AS lastModificationDate
42-
,sum(commitCount) AS commitCount
37+
,apoc.coll.toSet(apoc.coll.flatten(collect(commitHashes))) AS commitHashes
4338
,max(maxCommitSha) AS maxCommitSha
4439
,max(lastCommitDate) AS lastCommitDate
4540
,max(fileRelativePath) AS maxFileRelativePath
4641
,duration.inDays(max(lastCommitDate), date()).days AS daysSinceLastCommit
4742
,duration.inDays(max(fileCreatedAtTimestamp), datetime()).days AS daysSinceLastCreation
4843
,duration.inDays(max(fileLastModificationAtTimestamp), datetime()).days AS daysSinceLastModification
4944
// Assure that the authors are ordered by their commit count descending per directory
50-
ORDER BY directoryPath ASCENDING, commitCount DESCENDING
45+
ORDER BY directoryPath ASCENDING, size(commitHashes) DESCENDING
5146
WITH directoryPath
5247
,directoryName
5348
,directoryParentPath
5449
,directoryParentName
5550
,directoryPathLength
5651
,collect(author)[0] AS mainAuthor
57-
,collect(authorEmail)[0] AS mainAuthorEmail
58-
,collect(authorFull)[0] AS mainAuthorFull
5952
,collect(author)[1] AS secondAuthor
60-
,collect(authorEmail)[1] AS secondAuthorEmail
61-
,collect(authorFull)[1] AS secondAuthorFull
6253
,collect(author)[2] AS thirdAuthor
63-
,collect(authorEmail)[2] AS thirdAuthorEmail
64-
,collect(authorFull)[2] AS thirdAuthorFull
65-
,count(DISTINCT authorFull) AS authorCount
66-
,sum(fileCount) AS fileCount
67-
,sum(commitCount) AS commitCount
54+
,count(DISTINCT author) AS authorCount
55+
,size(apoc.coll.toSet(apoc.coll.flatten(collect(files)))) AS fileCount
56+
,size(apoc.coll.toSet(apoc.coll.flatten(collect(commitHashes)))) AS commitCount
6857
,max(lastCreationDate) AS lastCreationDate
6958
,max(lastModificationDate) AS lastModificationDate
7059
,max(maxCommitSha) AS maxCommitSha
@@ -79,14 +68,8 @@ RETURN collect(directoryPath)[-1] AS directoryPath
7968
,collect(directoryParentPath)[0] AS directoryParentPath
8069
,collect(directoryParentName)[0] AS directoryParentName
8170
,mainAuthor
82-
,mainAuthorEmail
83-
,mainAuthorFull
8471
,secondAuthor
85-
,secondAuthorEmail
86-
,secondAuthorFull
8772
,thirdAuthor
88-
,thirdAuthorEmail
89-
,thirdAuthorFull
9073
,authorCount
9174
,fileCount
9275
,commitCount

cypher/GitLog/List_git_file_directories_with_commit_statistics_by_author.cypher

Lines changed: 0 additions & 69 deletions
This file was deleted.

scripts/reports/GitHistoryCsv.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ echo "GitHistoryCsv: $(date +'%Y-%m-%dT%H:%M:%S%z') Processing git history..."
4242
# Detailed git file statistics
4343
execute_cypher "${GIT_LOG_CYPHER_DIR}/List_git_files_with_commit_statistics_by_author.cypher" > "${FULL_REPORT_DIRECTORY}/List_git_files_with_commit_statistics_by_author.csv"
4444
execute_cypher "${GIT_LOG_CYPHER_DIR}/List_git_files_that_were_changed_together_with_another_file.cypher" > "${FULL_REPORT_DIRECTORY}/List_git_files_that_were_changed_together_with_another_file.csv"
45-
execute_cypher "${GIT_LOG_CYPHER_DIR}/List_git_file_directories_with_commit_statistics_by_author.cypher" > "${FULL_REPORT_DIRECTORY}/List_git_file_directories_with_commit_statistics_by_author.csv"
4645
execute_cypher "${GIT_LOG_CYPHER_DIR}/List_git_file_directories_with_commit_statistics.cypher" > "${FULL_REPORT_DIRECTORY}/List_git_file_directories_with_commit_statistics.csv"
4746

4847
# Overall distribution of how many files were changed with one git commit, how many were changed with two, etc.

0 commit comments

Comments
 (0)