Thu, 13 May 2021 10:16:57 +0200
fixes missing issue sorting
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Tue May 11 17:41:01 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Thu May 13 10:16:57 2021 +0200 @@ -35,6 +35,7 @@ import de.uapcore.lightpit.types.WebColor import de.uapcore.lightpit.util.AllFilter import de.uapcore.lightpit.util.IssueFilter +import de.uapcore.lightpit.util.IssueSorter.Companion.DEFAULT_ISSUE_SORTER import de.uapcore.lightpit.util.SpecificFilter import de.uapcore.lightpit.viewmodel.* import java.sql.Date @@ -68,7 +69,7 @@ post("/%project/issues/%version/%component/-/commit", this::issueCommit) } - fun projects(http: HttpRequest, dao: DataAccessObject) { + private fun projects(http: HttpRequest, dao: DataAccessObject) { val projects = dao.listProjects() val projectInfos = projects.map { ProjectInfo( @@ -181,13 +182,14 @@ return PathInfos(projectInfo, version, component) } - fun project(http: HttpRequest, dao: DataAccessObject) { + private fun project(http: HttpRequest, dao: DataAccessObject) { withPathInfo(http, dao)?.run { + val issues = dao.listIssues(IssueFilter( project = SpecificFilter(projectInfo.project), version = version?.let { SpecificFilter(it) } ?: AllFilter(), component = component?.let { SpecificFilter(it) } ?: AllFilter() - )) + )).sortedWith(DEFAULT_ISSUE_SORTER) with(http) { view = ProjectDetails(projectInfo, issues, version, component) @@ -203,7 +205,7 @@ } } - fun projectForm(http: HttpRequest, dao: DataAccessObject) { + private fun projectForm(http: HttpRequest, dao: DataAccessObject) { val projectInfo = obtainProjectInfo(http, dao) if (projectInfo == null) { http.response.sendError(404) @@ -221,7 +223,7 @@ } } - fun projectCommit(http: HttpRequest, dao: DataAccessObject) { + private fun projectCommit(http: HttpRequest, dao: DataAccessObject) { // TODO: replace defaults with throwing validator exceptions val project = Project(http.param("id")?.toIntOrNull() ?: -1).apply { name = http.param("name") ?: "" @@ -247,7 +249,7 @@ http.renderCommit("projects/${project.node}") } - fun versions(http: HttpRequest, dao: DataAccessObject) { + private fun versions(http: HttpRequest, dao: DataAccessObject) { val projectInfo = obtainProjectInfo(http, dao) if (projectInfo == null) { http.response.sendError(404) @@ -268,7 +270,7 @@ } } - fun versionForm(http: HttpRequest, dao: DataAccessObject) { + private fun versionForm(http: HttpRequest, dao: DataAccessObject) { val projectInfo = obtainProjectInfo(http, dao) if (projectInfo == null) { http.response.sendError(404) @@ -298,7 +300,7 @@ } } - fun versionCommit(http: HttpRequest, dao: DataAccessObject) { + private fun versionCommit(http: HttpRequest, dao: DataAccessObject) { val id = http.param("id")?.toIntOrNull() val projectid = http.param("projectid")?.toIntOrNull() ?: -1 val project = dao.findProject(projectid) @@ -328,7 +330,7 @@ http.renderCommit("projects/${project.node}/versions/") } - fun components(http: HttpRequest, dao: DataAccessObject) { + private fun components(http: HttpRequest, dao: DataAccessObject) { val projectInfo = obtainProjectInfo(http, dao) if (projectInfo == null) { http.response.sendError(404) @@ -349,7 +351,7 @@ } } - fun componentForm(http: HttpRequest, dao: DataAccessObject) { + private fun componentForm(http: HttpRequest, dao: DataAccessObject) { val projectInfo = obtainProjectInfo(http, dao) if (projectInfo == null) { http.response.sendError(404) @@ -379,7 +381,7 @@ } } - fun componentCommit(http: HttpRequest, dao: DataAccessObject) { + private fun componentCommit(http: HttpRequest, dao: DataAccessObject) { val id = http.param("id")?.toIntOrNull() val projectid = http.param("projectid")?.toIntOrNull() ?: -1 val project = dao.findProject(projectid) @@ -413,7 +415,7 @@ http.renderCommit("projects/${project.node}/components/") } - fun issue(http: HttpRequest, dao: DataAccessObject) { + private fun issue(http: HttpRequest, dao: DataAccessObject) { withPathInfo(http, dao)?.run { val issue = dao.findIssue(http.pathParams["issue"]?.toIntOrNull() ?: -1) if (issue == null) { @@ -437,7 +439,7 @@ } } - fun issueForm(http: HttpRequest, dao: DataAccessObject) { + private fun issueForm(http: HttpRequest, dao: DataAccessObject) { withPathInfo(http, dao)?.run { val issue = dao.findIssue(http.pathParams["issue"]?.toIntOrNull() ?: -1) ?: Issue( -1, @@ -478,7 +480,7 @@ } } - fun issueComment(http: HttpRequest, dao: DataAccessObject) { + private fun issueComment(http: HttpRequest, dao: DataAccessObject) { withPathInfo(http, dao)?.run { val issue = dao.findIssue(http.pathParams["issue"]?.toIntOrNull() ?: -1) if (issue == null) { @@ -498,7 +500,7 @@ } } - fun issueCommit(http: HttpRequest, dao: DataAccessObject) { + private fun issueCommit(http: HttpRequest, dao: DataAccessObject) { withPathInfo(http, dao)?.run { // TODO: throw validator exception instead of using defaults val issue = Issue(
--- a/src/main/kotlin/de/uapcore/lightpit/util/Issues.kt Tue May 11 17:41:01 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/util/Issues.kt Thu May 13 10:16:57 2021 +0200 @@ -42,7 +42,15 @@ DONE, ETA, UPDATED } - data class Criteria(val field: Field, val asc: Boolean) + data class Criteria(val field: Field, val asc: Boolean = true) + + companion object { + val DEFAULT_ISSUE_SORTER = IssueSorter(listOf( + Criteria(Field.DONE), + Criteria(Field.UPDATED, false), + Criteria(Field.ETA) + )) + } override fun compare(left: Issue, right: Issue): Int { if (left == right) {