1+ // List git file directories and the number of files they contain
2+
3+ MATCH (git_file :File &Git &! Repository )
4+ WITH percentileDisc (git_file .createdAtEpoch , 0.5 ) AS medianCreatedAtEpoch
5+ ,percentileDisc (git_file .lastModificationAtEpoch , 0.5 ) AS medianLastModificationAtEpoch
6+ ,collect (git_file ) AS git_files
7+ UNWIND git_files AS git_file
8+ WITH *
9+ ,datetime .fromepochMillis (coalesce (git_file .createdAtEpoch , medianCreatedAtEpoch )) AS createdAtTimestamp
10+ ,datetime .fromepochMillis (coalesce (git_file .lastModificationAtEpoch , medianLastModificationAtEpoch )) AS lastModificationAtTimestamp
11+ WHERE git_file .deletedAt IS NULL
12+ MATCH (git_file :File &Git &! Repository )
13+ WITH * , split (git_file .relativePath , '/' ) AS pathElements
14+ WITH * , pathElements [- 1 ] AS fileName
15+ WITH *
16+ ,datetime .fromepochMillis (coalesce (git_file .createdAtEpoch , medianCreatedAtEpoch )) AS createdAtTimestamp
17+ ,datetime .fromepochMillis (coalesce (git_file .lastModificationAtEpoch , medianLastModificationAtEpoch )) AS lastModificationAtTimestamp
18+ OPTIONAL MATCH (git_repository :Git &Repository )- [ : HAS_FILE ] -> (git_file )
19+ OPTIONAL MATCH (git_commit :Git &Commit )- [ : CONTAINS_CHANGE ] -> (git_change :Git &Change )- [ ] -> (git_file )
20+ WITH * , sign (COUNT { (git_commit )- [: HAS_PARENT ]- (: Commit ) } ) AS parentCommit
21+ ORDER BY git_commit .date DESC
22+ UNWIND pathElements AS pathElement
23+ WITH *
24+ ,coalesce (nullif (split (git_file .relativePath , '/' + pathElement )[0 ], git_file .relativePath ), '' ) AS parent
25+ WITH *
26+ ,coalesce (nullif (parent ,'' ) + '/' , '' ) + pathElement AS directory
27+ ,fileName
28+ WHERE pathElement <> fileName
29+ WITH git_repository .name AS gitRepositoryName
30+ ,directory AS gitDirectoryPath
31+ ,parent AS directoryParentPath
32+ ,split (parent , '/' )[- 1 ] AS directoryParentPathName
33+ ,parent AS directoryParentName // TODO was directoryParentPathName
34+ ,split (directory , '/' )[- 1 ] AS directoryPathName
35+ ,directory AS directoryName // TODO was directoryPathName
36+ ,size (split (directory , '/' )) AS directoryPathLength
37+ ,count (DISTINCT git_file .relativePath ) AS fileCount
38+ ,count (DISTINCT git_commit .sha ) AS commitCount
39+ ,sum (parentCommit ) AS mergeCommitCount
40+ ,count (DISTINCT git_commit .author ) AS authorCount
41+ ,date (max (git_commit .date )) AS latestCommitDate
42+ ,max (date (createdAtTimestamp ) ) AS latestCreationDate
43+ ,max (date (lastModificationAtTimestamp )) AS latestModificationDate
44+ ,duration .inDays (date (max (git_commit .date )), date ()).days AS daysSinceLatestCommit
45+ ,duration .inDays (max (createdAtTimestamp ), datetime ()).days AS daysSinceLatestCreation
46+ ,duration .inDays (max (lastModificationAtTimestamp ), datetime ()).days AS daysSinceLatestModification
47+ ,collect (DISTINCT git_file .relativePath )[0 ..9 ] AS relativePathExamples
48+ ,collect (DISTINCT fileName )[0 ..9 ] AS fileNameExamples
49+ WHERE fileCount > 1 // Filter out single files and directories with only one file
50+ RETURN gitRepositoryName
51+ ,gitDirectoryPath
52+ ,directoryParentName
53+ ,directoryParentPathName // TODO rename or delete?
54+ ,directoryName
55+ ,directoryPathName // TODO rename or delete?
56+ ,directoryPathLength
57+ ,fileCount
58+ ,commitCount
59+ ,mergeCommitCount
60+ ,authorCount
61+ ,latestCommitDate
62+ ,latestCreationDate
63+ ,latestModificationDate
64+ ,daysSinceLatestCommit
65+ ,daysSinceLatestCreation
66+ ,daysSinceLatestModification
0 commit comments