# HG changeset patch # User Mike Becker # Date 1672761879 -3600 # Node ID 6a21bb926e0261e2bb9a93f854c568679340758b # Parent 7d67245e51211f5957ebc75b9bbd9b46cf22b996 add more possible sort criteria diff -r 7d67245e5121 -r 6a21bb926e02 src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt --- a/src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt Fri Dec 30 19:14:04 2022 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt Tue Jan 03 17:04:39 2023 +0100 @@ -62,5 +62,13 @@ eta == reference.eta && affected == reference.affected && resolved == reference.resolved) + + fun compareEtaTo(date: Date?): Int { + val eta = this.eta + return if (eta == null && date == null) 0 + else if (eta == null) 1 + else if (date == null) -1 + else eta.compareTo(date) + } } diff -r 7d67245e5121 -r 6a21bb926e02 src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt --- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Fri Dec 30 19:14:04 2022 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Tue Jan 03 17:04:39 2023 +0100 @@ -187,7 +187,7 @@ val issues = dao.listIssues(project, version, component) .sortedWith( IssueSorter( - IssueSorter.Criteria(IssueSorter.Field.PHASE), + IssueSorter.Criteria(IssueSorter.Field.STATUS), IssueSorter.Criteria(IssueSorter.Field.ETA), IssueSorter.Criteria(IssueSorter.Field.UPDATED, false) ) diff -r 7d67245e5121 -r 6a21bb926e02 src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt --- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt Fri Dec 30 19:14:04 2022 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt Tue Jan 03 17:04:39 2023 +0100 @@ -37,7 +37,7 @@ class IssueSorter(private vararg val criteria: Criteria) : Comparator { enum class Field { - PHASE, ETA, UPDATED + STATUS, CATEGORY, ETA, UPDATED, CREATED } data class Criteria(val field: Field, val asc: Boolean = true) @@ -48,16 +48,11 @@ } for (c in criteria) { val result = when (c.field) { - Field.PHASE -> left.status.phase.compareTo(right.status.phase) - Field.ETA -> { - val l = left.eta - val r = right.eta - if (l == null && r == null) 0 - else if (l == null) 1 - else if (r == null) -1 - else l.compareTo(r) - } + Field.STATUS -> left.status.compareTo(right.status) + Field.CATEGORY -> left.category.compareTo(right.category) + Field.ETA -> left.compareEtaTo(right.eta) Field.UPDATED -> left.updated.compareTo(right.updated) + Field.CREATED -> left.created.compareTo(right.created) } if (result != 0) { return if (c.asc) result else -result