Tue, 03 Jan 2023 17:04:39 +0100
add more possible sort criteria
--- 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) + } }
--- 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) )
--- 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<Issue> { 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