fix default sort criteria

Tue, 03 Jan 2023 18:25:51 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 03 Jan 2023 18:25:51 +0100
changeset 267
d8ec2d8ffa82
parent 266
65c72e65ff67
child 268
ca5501d851fa

fix default sort criteria

src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Tue Jan 03 18:19:40 2023 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Tue Jan 03 18:25:51 2023 +0100
@@ -187,7 +187,7 @@
             val issues = dao.listIssues(project, version, component)
                 .sortedWith(
                     IssueSorter(
-                        IssueSorter.Criteria(IssueSorter.Field.STATUS),
+                        IssueSorter.Criteria(IssueSorter.Field.DONE),
                         IssueSorter.Criteria(IssueSorter.Field.ETA),
                         IssueSorter.Criteria(IssueSorter.Field.UPDATED, false)
                     )
--- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Tue Jan 03 18:19:40 2023 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Tue Jan 03 18:25:51 2023 +0100
@@ -37,7 +37,7 @@
 
 class IssueSorter(private vararg val criteria: Criteria) : Comparator<Issue> {
     enum class Field {
-        STATUS, CATEGORY, ETA, UPDATED, CREATED
+        DONE, PHASE, STATUS, CATEGORY, ETA, UPDATED, CREATED
     }
 
     data class Criteria(val field: Field, val asc: Boolean = true)
@@ -48,6 +48,8 @@
         }
         for (c in criteria) {
             val result = when (c.field) {
+                Field.PHASE -> left.status.phase.compareTo(right.status.phase)
+                Field.DONE -> (left.status.phase == IssueStatusPhase.Done).compareTo(right.status.phase == IssueStatusPhase.Done)
                 Field.STATUS -> left.status.compareTo(right.status)
                 Field.CATEGORY -> left.category.compareTo(right.category)
                 Field.ETA -> left.compareEtaTo(right.eta)

mercurial