@@ -27,7 +27,9 @@ func getLabelForFileNode(currentFile fileInfo) string {
27
27
28
28
// fileInfoToCypher returns a cypher statement to create a node for a given file
29
29
func fileInfoToCypher (currentFile fileInfo , label string ) string {
30
- properties := ("{ name: '" + currentFile .Name + "', url: '" + currentFile .Url + "'" )
30
+ properties := ("{ name: '" + currentFile .Name +
31
+ "', url: '" + currentFile .Url +
32
+ "', _tempId: '" + currentFile .Id + "'" )
31
33
32
34
if (! currentFile .IsDir ) {
33
35
properties += (", " + "size: " + strconv .FormatInt (currentFile .Size , 10 ) + ", " +
@@ -66,11 +68,15 @@ func commitToCypher(fileId, contributerId string, contribution fileContribution)
66
68
// contributionToCypherUpdate returns a cypher statement to update a given contribution's commitCount
67
69
func contributionToCypherUpdate (contributionId string , commitCount int ) string {
68
70
return "MATCH (c:person)-[e:EDITED { _tempId: '" + contributionId + "' }]->(f:file) " +
69
- "SET e.commitCount = " + strconv .Itoa (commitCount ) + " " +
70
- "REMOVE e._tempId"
71
+ "SET e.commitCount = " + strconv .Itoa (commitCount )
71
72
}
72
73
73
74
// folderStructureToCypher returns to cypher statement to create a relationship between a file and its parent folder
74
75
func folderStructureToCypher (currentFile fileInfo ) string {
75
- return "CREATE (" + currentFile .Id + ")-[:IN_FOLDER]->(" + currentFile .ParentId + ")"
76
+ return "Match (a:directory { _tempId: '" + currentFile .ParentId + "' }) Match (b { _tempId: '" + currentFile .Id + "' }) CREATE (b)-[:IN_FOLDER]->(a)"
77
+ }
78
+
79
+ // returns a cypher statement that removes a given property from all nodes
80
+ func removeProperty (propertyName string ) string {
81
+ return "MATCH (a) REMOVE a." + propertyName
76
82
}
0 commit comments