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
+ WITH percentileDisc (git_file .createdAtEpoch , 0.5 ) AS medianCreatedAtEpoch
6
+ ,percentileDisc (git_file .lastModificationAtEpoch , 0.5 ) AS medianLastModificationAtEpoch
7
+ ,collect (git_file ) AS git_files
8
+ UNWIND git_files AS git_file
9
+ WITH *
10
+ ,datetime .fromepochMillis (coalesce (git_file .createdAtEpoch , medianCreatedAtEpoch )) AS fileCreatedAtTimestamp
11
+ ,datetime .fromepochMillis (coalesce (git_file .lastModificationAtEpoch , git_file .createdAtEpoch , medianLastModificationAtEpoch )) AS fileLastModificationAtTimestamp
12
+ MATCH (git_repository :Git &Repository )- [ : HAS_FILE ] -> (git_file )
13
+ MATCH (git_commit :Git &Commit )- [ : CONTAINS_CHANGE ] -> (git_change :Git &Change )- [ ] -> (git_file )
14
+ RETURN git_repository .name + '/' + git_file .relativePath AS filePath
15
+ ,split (git_commit .author , ' <' )[0 ] AS author
16
+ ,count (DISTINCT git_commit .sha ) AS commitCount
17
+ ,date (max (git_commit .date )) AS lastCommitDate
18
+ ,max (date (fileCreatedAtTimestamp )) AS lastCreationDate
19
+ ,max (date (fileLastModificationAtTimestamp )) AS lastModificationDate
20
+ ,duration .inDays (date (max (git_commit .date )), date ()).days AS daysSinceLastCommit
21
+ ,duration .inDays (max (fileCreatedAtTimestamp ), datetime ()).days AS daysSinceLastCreation
22
+ ,duration .inDays (max (fileLastModificationAtTimestamp ), datetime ()).days AS daysSinceLastModification
23
+ ,max (git_commit .sha ) AS maxCommitSha
24
+ ORDER BY filePath ASCENDING , commitCount DESCENDING
0 commit comments