Skip to content
This repository
Browse code

"fixed" dossiers - workaround possible gremlin bug

This is a very strange problem and I'm not certain exactly what to do
about it.  Basically, when creating dossiers on individual users it
appears that there are times when the pipe gets emptied out before all
of the data have been flushed through the pipe. I switched the
implementation some to use a loop for each type of EdgeType. It seems to
work.

Signed-off-by: Patrick Wagstrom <patrick@wagstrom.net>
  • Loading branch information...
commit 73e34855cbecca3e2bc9de8806e7f56bf513bb44 1 parent 05c0b67
Patrick Wagstrom authored

Showing 1 changed file with 61 additions and 27 deletions. Show diff stats Hide diff stats

  1. +61 27 src/main/gremlin/dossiers.grm
88 src/main/gremlin/dossiers.grm
@@ -14,7 +14,8 @@ def merge(Map a, Map b) {
14 14 return c
15 15 }
16 16
17   -def belongsToRepo(Vertex repo, Element e) {
  17 +def belongsToRepo(repo, e) {
  18 + // println("belongsToRepo: " + e + " " + e.label + " " + e.type)
18 19 switch (e.label) {
19 20 case null:
20 21 // kill null first as this is likely a vertex
@@ -49,9 +50,11 @@ def belongsToRepo(Vertex repo, Element e) {
49 50 // discussion_user
50 51 case VertexType.COMMENT:
51 52 // comment -> issue -> repository
  53 + // println("Returning: " + e.in(EdgeType.ISSUECOMMENT).in(EdgeType.ISSUE).next() + " " + repo)
52 54 return e.in(EdgeType.ISSUECOMMENT).in(EdgeType.ISSUE).next() == repo
53 55 case VertexType.COMMIT:
54 56 // commit -> repository
  57 + // println("Returning: " + e.out(EdgeType.REPOSITORY).next() + " " + repo)
55 58 return e.out(EdgeType.REPOSITORY).next() == repo
56 59 case VertexType.PULLREQUESTREVIEWCOMMENT:
57 60 // really not sure how to handle this...
@@ -61,38 +64,72 @@ def belongsToRepo(Vertex repo, Element e) {
61 64 // issue_event_actor
62 65 case VertexType.ISSUE_EVENT:
63 66 // issue event -> issue -> repository
  67 + // println("Returning: " + e.in(EdgeType.ISSUEEVENT).in(EdgeType.ISSUE).next() + " " + repo)
  68 +
64 69 return e.in("ISSUE_EVENT").in("ISSUE").next() == repo
65 70 case VertexType.ISSUE:
66 71 // issue -> repository
  72 + // println("Returning: " + e.in(EdgeType.ISSUE).next() + " " + repo)
  73 +
67 74 return e.in("ISSUE").next() == repo
68 75 case VertexType.PULLREQUEST:
69 76 // pullrequest -> repository
  77 + // println("Returning: " + e.in(EdgeType.PULLREQUEST).next() + " " + repo)
  78 +
70 79 return e.in("PULLREQUEST").next() == repo
71 80 // issue_event
72 81 // - issue_event
73 82 // git_user
74 83 // - commit
75 84 }
  85 + println("SHOULD NEVER REACH HERE!")
  86 + println("belongsToRepo: " + e + " " + e.label + " " + e.type)
  87 + return false
76 88 }
77 89 def getDossier(IndexableGraph g, Vertex repo, Vertex user) {
78   - // need to find a groovy equivalent of apply to clean this up
79   - gh_dossier = user.bothE(EdgeType.DISCUSSIONUSER, \
80   - EdgeType.ISSUEASSIGNEE, \
81   - EdgeType.ISSUECOMMENTOWNER, \
82   - EdgeType.ISSUEEVENTACTOR, \
83   - EdgeType.ISSUEOWNER, \
84   - EdgeType.PULLREQUESTCOMMENTOWNER, \
85   - EdgeType.PULLREQUESTISSUEUSER, \
86   - EdgeType.PULLREQUESTOWNER, \
87   - EdgeType.PULLREQUESTREVIEWCOMMENTOWNER). \
88   - filter{ belongsToRepo(repo, it) }. \
89   - groupCount{it.label}.cap.next()
90   - g_dossier = Helpers.getAllGitAccounts(g, user). \
91   - //_().in(EdgeType.COMMITAUTHOR, \
92   - //EdgeType.COMMITTER). \
93   - _().inE(EdgeType.COMMITTER). \
94   - filter{ belongsToRepo(repo, it) }. \
95   - groupCount{it.label}.cap.next()
  90 +
  91 +// For some reason this code seems to stop abnormally soon. I'm thinking it's a
  92 +// bug in gremlin or pipes. Use the new code below instead.
  93 +// // need to find a groovy equivalent of apply to clean this up
  94 +// gh_dossier = user.bothE(EdgeType.DISCUSSIONUSER, \
  95 +// EdgeType.ISSUEASSIGNEE, \
  96 +// EdgeType.ISSUECOMMENTOWNER, \
  97 +// EdgeType.ISSUEEVENTACTOR, \
  98 +// EdgeType.ISSUEOWNER, \
  99 +// EdgeType.PULLREQUESTCOMMENTOWNER, \
  100 +// EdgeType.PULLREQUESTISSUEUSER, \
  101 +// EdgeType.PULLREQUESTOWNER, \
  102 +// EdgeType.PULLREQUESTREVIEWCOMMENTOWNER). \
  103 +// filter{ belongsToRepo(repo, it) }. \
  104 +// groupCount{it.label}.cap.next()
  105 +
  106 + gh_dossier = [:]
  107 + gitHubEdgeTypes = [EdgeType.DISCUSSIONUSER, \
  108 + EdgeType.ISSUEASSIGNEE, \
  109 + EdgeType.ISSUECOMMENTOWNER, \
  110 + EdgeType.ISSUEEVENTACTOR, \
  111 + EdgeType.ISSUEOWNER, \
  112 + EdgeType.PULLREQUESTCOMMENTOWNER, \
  113 + EdgeType.PULLREQUESTISSUEUSER, \
  114 + EdgeType.PULLREQUESTOWNER, \
  115 + EdgeType.PULLREQUESTREVIEWCOMMENTOWNER]
  116 + for (et in gitHubEdgeTypes) {
  117 + user.bothE(et).filter{belongsToRepo(repo, it)}.label.groupCount(gh_dossier).iterate()
  118 + }
  119 +
  120 + g_dossier = [:]
  121 + gitEdgeTypes = [EdgeType.COMMITTER, EdgeType.COMMITAUTHOR]
  122 + allGitAccounts = Helpers.getAllGitAccounts(g, user)
  123 + for (et in gitEdgeTypes) {
  124 + allGitAccounts._().inE(et).filter{belongsToRepo(repo, it)}. \
  125 + label.groupCount(g_dossier).iterate()
  126 + }
  127 +// g_dossier = Helpers.getAllGitAccounts(g, user). \
  128 +// //_().in(EdgeType.COMMITAUTHOR, \
  129 +// //EdgeType.COMMITTER). \
  130 +// _().inE(EdgeType.COMMITTER). \
  131 +// filter{ belongsToRepo(repo, it) }. \
  132 +// groupCount{it.label}.cap.next()
96 133 return merge(gh_dossier, g_dossier)
97 134 }
98 135
@@ -113,20 +150,17 @@ def getDossierAsCSV(Vertex repo, Vertex user, Map dossier) {
113 150 dossier[EdgeType.COMMITTER] ?: 0 ].join(",")
114 151 }
115 152
116   -// g = new Neo4jGraph(Defaults.DBPATH)
117   -
118   -//projects = Defaults.PROJECTS
119   -//projects = ["rails/rails", "rack/rack", "sinatra/sinatra"]
  153 +configMap = ["READ_ONLY": true]
  154 +g = new Neo4jGraph(Defaults.DBPATH, configMap)
120 155 projects = ["rails/rails"]
121   -//user = repo.in("REPO_OWNER").next()
122 156
123 157 // header
124 158 // TODO clean this up, need to unify all of the points where these fields are referenced
125 159 println "repository,username,email,issueassignee,issuecommentowner,issueeventactor,issueowner,pullrequestcommentowner,pullrequestreviewcommentowner,committer"
126 160 for (project in projects) {
127 161 repo = g.idx(IndexNames.REPOSITORY).get(IdCols.REPOSITORY, project).next()
128   - users = [g.idx(IndexNames.USER).get(IdCols.USER, "dhh").next()]
129   - // users = Helpers.getAllRepositoryUsers(repo)
  162 + // users = [g.idx(IndexNames.USER).get(IdCols.USER, "dhh").next()]
  163 + users = Helpers.getAllRepositoryUsers(repo)
130 164 for (user in users) {
131 165 if (user instanceof Vertex) {
132 166 println getDossierAsCSV(repo, user, getDossier(g, repo, user))
@@ -137,5 +171,5 @@ for (project in projects) {
137 171 }
138 172 }
139 173
140   -// g.shutdown()
  174 +g.shutdown()
141 175

0 comments on commit 73e3485

Please sign in to comment.
Something went wrong with that request. Please try again.