--- app/controllers/MigrationApp.java
+++ app/controllers/MigrationApp.java
... | ... | @@ -146,6 +146,18 @@ |
146 | 146 |
return members; |
147 | 147 |
} |
148 | 148 |
|
149 |
+ public static List<ObjectNode> getAuthors(Project project) { |
|
150 |
+ List<ObjectNode> authors = new ArrayList<>(); |
|
151 |
+ for(User user: project.findAuthors()){ |
|
152 |
+ ObjectNode member = Json.newObject(); |
|
153 |
+ member.put("name", user.name); |
|
154 |
+ member.put("login", user.loginId); |
|
155 |
+ member.put("email", user.email); |
|
156 |
+ authors.add(member); |
|
157 |
+ } |
|
158 |
+ return authors; |
|
159 |
+ } |
|
160 |
+ |
|
149 | 161 |
@AnonymousCheck(requiresLogin = true, displaysFlashMessage = true) |
150 | 162 |
public static Result exportIssueLabelPairs(String owner, String projectName){ |
151 | 163 |
ObjectNode issueLabelPairs = composeIssueLabelPairJson(owner, projectName); |
--- app/controllers/ProjectApp.java
+++ app/controllers/ProjectApp.java
... | ... | @@ -828,7 +828,7 @@ |
828 | 828 |
return; |
829 | 829 |
} |
830 | 830 |
|
831 |
- for (User user : findAuthorsAndWatchers(project)) { |
|
831 |
+ for (User user : project.findAuthorsAndWatchers()) { |
|
832 | 832 |
if (!userList.contains(user)) { |
833 | 833 |
userList.add(user); |
834 | 834 |
} |
... | ... | @@ -1226,36 +1226,4 @@ |
1226 | 1226 |
} |
1227 | 1227 |
return ok(); |
1228 | 1228 |
} |
1229 |
- |
|
1230 |
- public static Set<User> findAuthorsAndWatchers(@Nonnull Project project) { |
|
1231 |
- Set<User> allAuthors = new LinkedHashSet<>(); |
|
1232 |
- |
|
1233 |
- allAuthors.addAll(getIssueUsers(project)); |
|
1234 |
- allAuthors.addAll(getPostingUsers(project)); |
|
1235 |
- allAuthors.addAll(getPullRequestUsers(project)); |
|
1236 |
- allAuthors.addAll(getWatchedUsers(project)); |
|
1237 |
- |
|
1238 |
- return allAuthors; |
|
1239 |
- } |
|
1240 |
- |
|
1241 |
- private static Set<User> getPostingUsers(Project project) { |
|
1242 |
- String postSql = "SELECT distinct author_id id FROM posting where project_id=" + project.id; |
|
1243 |
- return User.find.setRawSql(RawSqlBuilder.parse(postSql).create()).findSet(); |
|
1244 |
- } |
|
1245 |
- |
|
1246 |
- private static Set<User> getIssueUsers(Project project) { |
|
1247 |
- String issueSql = "SELECT distinct author_id id FROM ISSUE where project_id=" + project.id; |
|
1248 |
- return User.find.setRawSql(RawSqlBuilder.parse(issueSql).create()).findSet(); |
|
1249 |
- } |
|
1250 |
- |
|
1251 |
- private static Set<User> getPullRequestUsers(Project project) { |
|
1252 |
- String postSql = "SELECT distinct contributor_id id FROM pull_request where to_project_id=" + project.id; |
|
1253 |
- return User.find.setRawSql(RawSqlBuilder.parse(postSql).create()).findSet(); |
|
1254 |
- } |
|
1255 |
- |
|
1256 |
- private static Set<User> getWatchedUsers(Project project) { |
|
1257 |
- String postSql = "SELECT distinct user_id id FROM watch where resource_type='PROJECT' and resource_id=" + project.id; |
|
1258 |
- return User.find.setRawSql(RawSqlBuilder.parse(postSql).create()).findSet(); |
|
1259 |
- } |
|
1260 |
- |
|
1261 | 1229 |
} |
--- app/controllers/api/ProjectApi.java
+++ app/controllers/api/ProjectApi.java
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 |
import java.util.stream.Collectors; |
26 | 26 |
|
27 | 27 |
import static controllers.MigrationApp.composePlainCommentsJson; |
28 |
-import static controllers.MigrationApp.getAssginees; |
|
28 |
+import static controllers.MigrationApp.*; |
|
29 | 29 |
import static models.AbstractPosting.findByProject; |
30 | 30 |
import static play.libs.Json.toJson; |
31 | 31 |
|
... | ... | @@ -40,6 +40,7 @@ |
40 | 40 |
json.put("projectName", project.name); |
41 | 41 |
json.put("projectDescription", project.overview); |
42 | 42 |
json.put("assignees", toJson(getAssginees(project).toArray())); |
43 |
+ json.put("authors", toJson(getAuthors(project).toArray())); |
|
43 | 44 |
json.put("memberCount", project.members().size()); |
44 | 45 |
json.put("members", project.members().size()); |
45 | 46 |
Optional.ofNullable(project.members()) |
--- app/models/Project.java
+++ app/models/Project.java
... | ... | @@ -9,6 +9,7 @@ |
9 | 9 |
import com.avaje.ebean.Ebean; |
10 | 10 |
import com.avaje.ebean.ExpressionList; |
11 | 11 |
import com.avaje.ebean.Page; |
12 |
+import com.avaje.ebean.RawSqlBuilder; |
|
12 | 13 |
import models.enumeration.ProjectScope; |
13 | 14 |
import models.enumeration.RequestState; |
14 | 15 |
import models.enumeration.ResourceType; |
... | ... | @@ -35,10 +36,7 @@ |
35 | 36 |
import javax.persistence.*; |
36 | 37 |
import javax.servlet.ServletException; |
37 | 38 |
import java.io.IOException; |
38 |
-import java.util.ArrayList; |
|
39 |
-import java.util.Date; |
|
40 |
-import java.util.List; |
|
41 |
-import java.util.Set; |
|
39 |
+import java.util.*; |
|
42 | 40 |
|
43 | 41 |
import static utils.CacheStore.getProjectCacheKey; |
44 | 42 |
import static utils.CacheStore.projectMap; |
... | ... | @@ -175,6 +173,43 @@ |
175 | 173 |
} |
176 | 174 |
} |
177 | 175 |
|
176 |
+ public Set<User> findAuthors() { |
|
177 |
+ Set<User> allAuthors = new LinkedHashSet<>(); |
|
178 |
+ allAuthors.addAll(getIssueUsers()); |
|
179 |
+ allAuthors.addAll(getPostingUsers()); |
|
180 |
+ allAuthors.addAll(getPullRequestUsers()); |
|
181 |
+ |
|
182 |
+ return allAuthors; |
|
183 |
+ } |
|
184 |
+ |
|
185 |
+ public Set<User> findAuthorsAndWatchers() { |
|
186 |
+ Set<User> allAuthors = new LinkedHashSet<>(); |
|
187 |
+ allAuthors.addAll(findAuthors()); |
|
188 |
+ allAuthors.addAll(getWatchedUsers()); |
|
189 |
+ |
|
190 |
+ return allAuthors; |
|
191 |
+ } |
|
192 |
+ |
|
193 |
+ private Set<User> getIssueUsers() { |
|
194 |
+ String issueSql = "SELECT distinct author_id id FROM ISSUE where project_id=" + this.id; |
|
195 |
+ return User.find.setRawSql(RawSqlBuilder.parse(issueSql).create()).findSet(); |
|
196 |
+ } |
|
197 |
+ |
|
198 |
+ private Set<User> getPostingUsers() { |
|
199 |
+ String postSql = "SELECT distinct author_id id FROM posting where project_id=" + this.id; |
|
200 |
+ return User.find.setRawSql(RawSqlBuilder.parse(postSql).create()).findSet(); |
|
201 |
+ } |
|
202 |
+ |
|
203 |
+ private Set<User> getPullRequestUsers() { |
|
204 |
+ String postSql = "SELECT distinct contributor_id id FROM pull_request where to_project_id=" + this.id; |
|
205 |
+ return User.find.setRawSql(RawSqlBuilder.parse(postSql).create()).findSet(); |
|
206 |
+ } |
|
207 |
+ |
|
208 |
+ public Set<User> getWatchedUsers() { |
|
209 |
+ String postSql = "SELECT distinct user_id id FROM watch where resource_type='PROJECT' and resource_id=" + this.id; |
|
210 |
+ return User.find.setRawSql(RawSqlBuilder.parse(postSql).create()).findSet(); |
|
211 |
+ } |
|
212 |
+ |
|
178 | 213 |
public boolean hasMember(User user) { |
179 | 214 |
if (user.isMemberOf(this) || |
180 | 215 |
user.isManagerOf(this) || |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?