[Notice] Announcing the End of Demo Server [Read me]
--- app/models/Issue.java
+++ app/models/Issue.java
... | ... | @@ -691,4 +691,11 @@ |
691 | 691 |
public List<IssueSharer> getSortedSharer() { |
692 | 692 |
return new ArrayList<>(sharers); |
693 | 693 |
} |
694 |
+ |
|
695 |
+ public static int getCountOfMentionedOpenIssues(Long userId) { |
|
696 |
+ return finder.where() |
|
697 |
+ .in("id", Mention.getMentioningIssueIds(userId)) |
|
698 |
+ .eq("state", State.OPEN) |
|
699 |
+ .findRowCount(); |
|
700 |
+ } |
|
694 | 701 |
} |
--- app/models/Mention.java
+++ app/models/Mention.java
... | ... | @@ -1,23 +1,10 @@ |
1 | 1 |
/** |
2 |
- * Yobi, Project Hosting SW |
|
3 |
- * |
|
4 |
- * Copyright 2014 NAVER Corp. |
|
5 |
- * http://yobi.io |
|
6 |
- * |
|
7 |
- * @author Yi EungJun |
|
8 |
- * |
|
9 |
- * Licensed under the Apache License, Version 2.0 (the "License"); |
|
10 |
- * you may not use this file except in compliance with the License. |
|
11 |
- * You may obtain a copy of the License at |
|
12 |
- * |
|
13 |
- * http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
- * |
|
15 |
- * Unless required by applicable law or agreed to in writing, software |
|
16 |
- * distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
- * See the License for the specific language governing permissions and |
|
19 |
- * limitations under the License. |
|
20 |
- */ |
|
2 |
+ * Yona, 21st Century Project Hosting SW |
|
3 |
+ * <p> |
|
4 |
+ * Copyright Yona & Yobi Authors & NAVER Corp. & NAVER LABS Corp. |
|
5 |
+ * https://yona.io |
|
6 |
+ **/ |
|
7 |
+ |
|
21 | 8 |
package models; |
22 | 9 |
|
23 | 10 |
import models.enumeration.ResourceType; |
... | ... | @@ -27,7 +14,13 @@ |
27 | 14 |
import javax.persistence.Entity; |
28 | 15 |
import javax.persistence.Id; |
29 | 16 |
import javax.persistence.ManyToOne; |
17 |
+import java.util.ArrayList; |
|
18 |
+import java.util.HashSet; |
|
19 |
+import java.util.List; |
|
30 | 20 |
import java.util.Set; |
21 |
+ |
|
22 |
+import static models.enumeration.ResourceType.ISSUE_COMMENT; |
|
23 |
+import static models.enumeration.ResourceType.ISSUE_POST; |
|
31 | 24 |
|
32 | 25 |
@Entity |
33 | 26 |
public class Mention extends Model { |
... | ... | @@ -73,4 +66,37 @@ |
73 | 66 |
mention.save(); |
74 | 67 |
} |
75 | 68 |
} |
69 |
+ |
|
70 |
+ public static List<Long> getMentioningIssueIds(Long mentionUserId) { |
|
71 |
+ Set<Long> ids = new HashSet<>(); |
|
72 |
+ Set<Long> commentIds = new HashSet<>(); |
|
73 |
+ |
|
74 |
+ for (Mention mention : Mention.find.where() |
|
75 |
+ .eq("user.id", mentionUserId) |
|
76 |
+ .in("resourceType", ISSUE_POST, ISSUE_COMMENT) |
|
77 |
+ .findList()) { |
|
78 |
+ |
|
79 |
+ switch (mention.resourceType) { |
|
80 |
+ case ISSUE_POST: |
|
81 |
+ ids.add(Long.valueOf(mention.resourceId)); |
|
82 |
+ break; |
|
83 |
+ case ISSUE_COMMENT: |
|
84 |
+ commentIds.add(Long.valueOf(mention.resourceId)); |
|
85 |
+ break; |
|
86 |
+ default: |
|
87 |
+ play.Logger.warn("'" + mention.resourceType + "' is not supported."); |
|
88 |
+ break; |
|
89 |
+ } |
|
90 |
+ } |
|
91 |
+ |
|
92 |
+ if (!commentIds.isEmpty()) { |
|
93 |
+ for (IssueComment comment : IssueComment.find.where() |
|
94 |
+ .idIn(new ArrayList<>(commentIds)) |
|
95 |
+ .findList()) { |
|
96 |
+ ids.add(comment.issue.id); |
|
97 |
+ } |
|
98 |
+ } |
|
99 |
+ |
|
100 |
+ return new ArrayList<>(ids); |
|
101 |
+ } |
|
76 | 102 |
} |
--- app/models/support/SearchCondition.java
+++ app/models/support/SearchCondition.java
... | ... | @@ -21,9 +21,6 @@ |
21 | 21 |
import java.text.SimpleDateFormat; |
22 | 22 |
import java.util.*; |
23 | 23 |
|
24 |
-import static models.enumeration.ResourceType.ISSUE_COMMENT; |
|
25 |
-import static models.enumeration.ResourceType.ISSUE_POST; |
|
26 |
- |
|
27 | 24 |
public class SearchCondition extends AbstractPostingApp.SearchCondition implements Cloneable { |
28 | 25 |
public String state; |
29 | 26 |
public Boolean commentedCheck; |
... | ... | @@ -304,7 +301,7 @@ |
304 | 301 |
if (mentionId != null) { |
305 | 302 |
User mentionUser = User.find.byId(mentionId); |
306 | 303 |
if(!mentionUser.isAnonymous()) { |
307 |
- List<Long> ids = getMentioningIssueIds(mentionUser); |
|
304 |
+ List<Long> ids = Mention.getMentioningIssueIds(mentionId); |
|
308 | 305 |
|
309 | 306 |
if (ids.isEmpty()) { |
310 | 307 |
// No need to progress because the query matches nothing. |
... | ... | @@ -351,39 +348,6 @@ |
351 | 348 |
} |
352 | 349 |
} |
353 | 350 |
return new ArrayList<>(issueIds); |
354 |
- } |
|
355 |
- |
|
356 |
- private List<Long> getMentioningIssueIds(User mentionUser) { |
|
357 |
- Set<Long> ids = new HashSet<>(); |
|
358 |
- Set<Long> commentIds = new HashSet<>(); |
|
359 |
- |
|
360 |
- for (Mention mention : Mention.find.where() |
|
361 |
- .eq("user", mentionUser) |
|
362 |
- .in("resourceType", ISSUE_POST, ISSUE_COMMENT) |
|
363 |
- .findList()) { |
|
364 |
- |
|
365 |
- switch (mention.resourceType) { |
|
366 |
- case ISSUE_POST: |
|
367 |
- ids.add(Long.valueOf(mention.resourceId)); |
|
368 |
- break; |
|
369 |
- case ISSUE_COMMENT: |
|
370 |
- commentIds.add(Long.valueOf(mention.resourceId)); |
|
371 |
- break; |
|
372 |
- default: |
|
373 |
- play.Logger.warn("'" + mention.resourceType + "' is not supported."); |
|
374 |
- break; |
|
375 |
- } |
|
376 |
- } |
|
377 |
- |
|
378 |
- if (!commentIds.isEmpty()) { |
|
379 |
- for (IssueComment comment : IssueComment.find.where() |
|
380 |
- .idIn(new ArrayList<>(commentIds)) |
|
381 |
- .findList()) { |
|
382 |
- ids.add(comment.issue.id); |
|
383 |
- } |
|
384 |
- } |
|
385 |
- |
|
386 |
- return new ArrayList<>(ids); |
|
387 | 351 |
} |
388 | 352 |
|
389 | 353 |
private List<Long> getSharedIssueIds(User user) { |
--- app/views/issue/my_partial_list_quicksearch.scala.html
+++ app/views/issue/my_partial_list_quicksearch.scala.html
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 |
* https://yona.io |
6 | 6 |
**@ |
7 | 7 |
@import models.support.SearchCondition |
8 |
+@import org.apache.commons.lang3.StringUtils |
|
8 | 9 |
@(param:SearchCondition) |
9 | 10 |
|
10 | 11 |
@currentUserId = @{ |
... | ... | @@ -54,7 +55,9 @@ |
54 | 55 |
data-milestone-id="@param.milestoneId" |
55 | 56 |
data-mention-id="@currentUserId" |
56 | 57 |
data-sharer-id=""> |
57 |
- @Messages("issue.list.mentionedOfMe") |
|
58 |
+ @Messages("issue.list.mentionedOfMe") @if(StringUtils.isBlank(param.filter)) { |
|
59 |
+ (@Issue.getCountOfMentionedOpenIssues(currentUserId)) |
|
60 |
+ } |
|
58 | 61 |
</a> |
59 | 62 |
</li> |
60 | 63 |
<li @if(param.sharerId == currentUserId){ class="active"}> |
... | ... | @@ -65,7 +68,9 @@ |
65 | 68 |
data-milestone-id="@param.milestoneId" |
66 | 69 |
data-mention-id="" |
67 | 70 |
data-sharer-id="@currentUserId"> |
68 |
- @Messages("issue.list.sharedWithMe") (@IssueSharer.getNumberOfIssuesSharedWithUser(currentUserId)) |
|
71 |
+ @Messages("issue.list.sharedWithMe") @if(StringUtils.isBlank(param.filter)) { |
|
72 |
+ (@IssueSharer.getNumberOfIssuesSharedWithUser(currentUserId)) |
|
73 |
+ } |
|
69 | 74 |
</a> |
70 | 75 |
</li> |
71 | 76 |
} |
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?