|
| 1 | +// List git files with commit statistics |
| 2 | + |
| 3 | + MATCH (git_file:File&Git&!Repository) |
| 4 | + WHERE git_file.deletedAt IS NULL // filter out deleted files |
| 5 | + ORDER BY git_file.relativePath |
| 6 | + WITH percentileDisc(git_file.createdAtEpoch, 0.5) AS medianCreatedAtEpoch |
| 7 | + ,percentileDisc(git_file.lastModificationAtEpoch, 0.5) AS medianLastModificationAtEpoch |
| 8 | + ,collect(git_file) AS git_files |
| 9 | +UNWIND git_files AS git_file |
| 10 | + WITH * |
| 11 | + ,datetime.fromepochMillis(coalesce(git_file.createdAtEpoch, medianCreatedAtEpoch)) AS fileCreatedAtTimestamp |
| 12 | + ,datetime.fromepochMillis(coalesce(git_file.lastModificationAtEpoch, medianLastModificationAtEpoch)) AS fileLastModificationAtTimestamp |
| 13 | + MATCH (git_repository:Git&Repository)-[:HAS_FILE]->(git_file) |
| 14 | + MATCH (git_commit:Git&Commit)-[:CONTAINS_CHANGE]->(git_change:Git&Change)-[]->(git_file) |
| 15 | + WITH *, split(git_commit.author, ' <')[0] AS author |
| 16 | + WITH git_repository.name + '/' + git_file.relativePath AS filePath |
| 17 | + ,author |
| 18 | + ,split(git_commit.author, ' <')[0] AS commitCountAuthor |
| 19 | + ,count(DISTINCT git_commit.sha) AS commitCount |
| 20 | + ,date(max(git_commit.date)) AS lastCommitDate |
| 21 | + ,max(date(fileCreatedAtTimestamp)) AS lastCreationDate |
| 22 | + ,max(date(fileLastModificationAtTimestamp)) AS lastModificationDate |
| 23 | + ,duration.inDays(date(max(git_commit.date)), date()).days AS daysSinceLastCommit |
| 24 | + ,duration.inDays(max(fileCreatedAtTimestamp), datetime()).days AS daysSinceLastCreation |
| 25 | + ,duration.inDays(max(fileLastModificationAtTimestamp), datetime()).days AS daysSinceLastModification |
| 26 | + ,max(git_commit.sha) AS maxCommitSha |
| 27 | +ORDER BY filePath ASCENDING, commitCount DESCENDING |
| 28 | +RETURN filePath |
| 29 | + ,collect(DISTINCT author)[0] AS mainAuthor |
| 30 | + ,count(DISTINCT author) AS authorCount |
| 31 | + ,sum(commitCount) AS commitCount |
| 32 | + ,max(lastCommitDate) AS lastCommitDate |
| 33 | + ,max() |
| 34 | + ,min(daysSinceLastCommit) AS daysSinceLastCommit |
| 35 | + ,min(daysSinceLastCreation) AS daysSinceLastCreation |
| 36 | + ,min(daysSinceLastModification) AS daysSinceLastModification |
| 37 | + ,max(maxCommitSha) AS maxCommitSha |
0 commit comments