[Notice] Announcing the End of Demo Server [Read me]
Merge pull request #42.ㅍㄿㄹOpen from wansoon/HIVE-192
HIVE-192 마일스톤 보기에서 '완료율 순'을 누르면 에러
@977c725740cce382a7d98a1056f8c12c56bfa30f
--- app/models/Milestone.java
+++ app/models/Milestone.java
... | ... | @@ -58,11 +58,11 @@ |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
public int getNumClosedIssues() { |
61 |
- return Issue.finder.where().eq("milestone", this).eq("state", State.CLOSED).findRowCount(); |
|
61 |
+ return Issue.finder.where().eq("milestone", this).eq("state", State.CLOSED).findRowCount(); |
|
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
public int getNumOpenIssues() { |
65 |
- return Issue.finder.where().eq("milestone", this).eq("state", State.OPEN).findRowCount(); |
|
65 |
+ return Issue.finder.where().eq("milestone", this).eq("state", State.OPEN).findRowCount(); |
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
public int getNumTotalIssues() { |
... | ... | @@ -139,13 +139,38 @@ |
139 | 139 |
* @return |
140 | 140 |
*/ |
141 | 141 |
public static List<Milestone> findMilestones(Long projectId, |
142 |
- State state, String sort, Direction direction) { |
|
143 |
- OrderParams orderParams = new OrderParams().add(sort, direction); |
|
142 |
+ State state, String sort, final Direction direction) { |
|
143 |
+ |
|
144 |
+ OrderParams orderParams = new OrderParams(); |
|
145 |
+ |
|
146 |
+ if(!"completionRate".equals(sort)) { |
|
147 |
+ orderParams.add(sort, direction); |
|
148 |
+ } |
|
149 |
+ |
|
144 | 150 |
SearchParams searchParams = new SearchParams().add("project.id", projectId, Matching.EQUALS); |
145 |
- if (state != null && state != State.ALL) { |
|
151 |
+ if(state != null && state != State.ALL) { |
|
146 | 152 |
searchParams.add("state", state, Matching.EQUALS); |
147 | 153 |
} |
148 |
- return FinderTemplate.findBy(orderParams, searchParams, find); |
|
154 |
+ |
|
155 |
+ List<Milestone> milestones = FinderTemplate.findBy(orderParams, searchParams, find); |
|
156 |
+ |
|
157 |
+ if("completionRate".equals(sort)) { |
|
158 |
+ Collections.sort(milestones, new Comparator<Milestone>() { |
|
159 |
+ @Override |
|
160 |
+ public int compare(Milestone o1, Milestone o2) { |
|
161 |
+ int o1CompletionRate = o1.getCompletionRate(); |
|
162 |
+ int o2CompletionRate = o2.getCompletionRate(); |
|
163 |
+ |
|
164 |
+ if(direction == Direction.ASC) { |
|
165 |
+ return (o1CompletionRate < o2CompletionRate ? -1 : (o1CompletionRate == o2CompletionRate ? 0 : 1)); |
|
166 |
+ } else { |
|
167 |
+ return (o1CompletionRate < o2CompletionRate ? 1 : (o1CompletionRate == o2CompletionRate ? 0 : -1)); |
|
168 |
+ } |
|
169 |
+ } |
|
170 |
+ }); |
|
171 |
+ } |
|
172 |
+ |
|
173 |
+ return milestones; |
|
149 | 174 |
} |
150 | 175 |
|
151 | 176 |
public void updateWith(Milestone newMilestone) { |
--- app/views/milestone/manage.scala.html
+++ app/views/milestone/manage.scala.html
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 |
<td><a href="@makeSortLink("title")">@Messages("label.title") @sortMark("title")</a></td> |
56 | 56 |
<td>@Messages("label.contents")</td> |
57 | 57 |
<td><a href="@makeSortLink("dueDate")">@Messages("label.dueDate") @sortMark("dueDate")</a></td> |
58 |
- <td><a href="@makeSortLink("completionRate")">@Messages("label.state") @sortMark("completionRate")</a></td> |
|
58 |
+ <td><a href="@makeSortLink("state")">@Messages("label.state") @sortMark("state")</a></td> |
|
59 | 59 |
<td> </td> |
60 | 60 |
</tr> |
61 | 61 |
</thead> |
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?