From 3a2908c3a3be98a82f0c50f1d5c4b0387ef1471e Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Tue, 13 Sep 2022 23:19:38 +0900 Subject: [PATCH] Resurrect assignee icons on the issue list (#3136) --- .../controller/PrioritiesController.scala | 6 ++-- .../core/service/IssuesService.scala | 34 +++++++++++-------- .../core/dashboard/issueslist.scala.html | 6 ++-- .../core/issues/listparts.scala.html | 6 ++-- .../issues/milestones/listparts.scala.html | 6 ++-- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/PrioritiesController.scala b/src/main/scala/gitbucket/core/controller/PrioritiesController.scala index f34ed63b6..6231863fc 100644 --- a/src/main/scala/gitbucket/core/controller/PrioritiesController.scala +++ b/src/main/scala/gitbucket/core/controller/PrioritiesController.scala @@ -45,7 +45,7 @@ trait PrioritiesControllerBase extends ControllerBase { get("/:owner/:repository/issues/priorities")(referrersOnly { repository => html.list( getPriorities(repository.owner, repository.name), - countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty), + countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()), repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount) ) @@ -60,7 +60,7 @@ trait PrioritiesControllerBase extends ControllerBase { createPriority(repository.owner, repository.name, form.priorityName, form.description, form.color.substring(1)) html.priority( getPriority(repository.owner, repository.name, priorityId).get, - countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty), + countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()), repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount) ) @@ -84,7 +84,7 @@ trait PrioritiesControllerBase extends ControllerBase { ) html.priority( getPriority(repository.owner, repository.name, params("priorityId").toInt).get, - countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty), + countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()), repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount) ) diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index cbe2802b3..f851b8802 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -147,7 +147,7 @@ trait IssuesService { t3.labelName } .map { - case labelName ~ t => + case (labelName, t) => labelName -> t.length } .list @@ -165,8 +165,7 @@ trait IssuesService { def countIssueGroupByPriorities( owner: String, repository: String, - condition: IssueSearchCondition, - filterUser: Map[String, String] + condition: IssueSearchCondition )(implicit s: Session): Map[String, Int] = { searchIssueQuery(Seq(owner -> repository), condition.copy(labels = Set.empty), IssueSearchOption.Issues) @@ -180,7 +179,7 @@ trait IssuesService { t2.priorityName } .map { - case priorityName ~ t => + case (priorityName, t) => priorityName -> t.length } .list @@ -216,9 +215,11 @@ trait IssuesService { .on { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 => t1.byPriority(t6.userName, t6.repositoryName, t6.priorityId) } .joinLeft(PullRequests) .on { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 ~ t7 => t1.byIssue(t7.userName, t7.repositoryName, t7.issueId) } - .sortBy { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 ~ t7 => i asc } + .joinLeft(IssueAssignees) + .on { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 ~ t7 ~ t8 => t1.byIssue(t8.userName, t8.repositoryName, t8.issueId) } + .sortBy { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 ~ t7 ~ t8 => i asc } .map { - case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 ~ t7 => + case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 ~ t7 ~ t8 => ( t1, t2.commentCount, @@ -227,7 +228,8 @@ trait IssuesService { t4.map(_.color), t5.map(_.title), t6.map(_.priorityName), - t7.map(_.commitIdTo) + t7.map(_.commitIdTo), + t8.map(_.assigneeUserName) ) } .list @@ -237,7 +239,7 @@ trait IssuesService { result.map { issues => issues.head match { - case (issue, commentCount, _, _, _, milestone, priority, commitId) => + case (issue, commentCount, _, _, _, milestone, priority, commitId, _) => IssueInfo( issue, issues.flatMap { t => @@ -246,7 +248,8 @@ trait IssuesService { milestone, priority, commentCount, - commitId + commitId, + issues.flatMap(_._9) ) } } toList @@ -270,7 +273,7 @@ trait IssuesService { .map { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 => (t1, t3, t5) } .list .groupBy { - case (issue, account, assignedUsers) => + case (issue, account, _) => (issue, account) } .map { @@ -748,12 +751,12 @@ trait IssuesService { s: Session ): Int = { Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(_.updatedDate).update(currentDate) - IssueComments.filter(_.byPrimaryKey(commentId)).firstOption match { - case Some(c) if c.action == "reopen_comment" => + IssueComments.filter(_.byPrimaryKey(commentId)).first match { + case c if c.action == "reopen_comment" => IssueComments.filter(_.byPrimaryKey(commentId)).map(t => (t.content, t.action)).update("Reopen", "reopen") - case Some(c) if c.action == "close_comment" => + case c if c.action == "close_comment" => IssueComments.filter(_.byPrimaryKey(commentId)).map(t => (t.content, t.action)).update("Close", "close") - case Some(_) => + case _ => IssueComments.filter(_.byPrimaryKey(commentId)).delete IssueComments insert IssueComment( userName = owner, @@ -1084,7 +1087,8 @@ object IssuesService { milestone: Option[String], priority: Option[String], commentCount: Int, - commitId: Option[String] + commitId: Option[String], + assignees: Seq[String] ) } diff --git a/src/main/twirl/gitbucket/core/dashboard/issueslist.scala.html b/src/main/twirl/gitbucket/core/dashboard/issueslist.scala.html index d0ef372df..4bf4fe142 100644 --- a/src/main/twirl/gitbucket/core/dashboard/issueslist.scala.html +++ b/src/main/twirl/gitbucket/core/dashboard/issueslist.scala.html @@ -17,7 +17,7 @@ - @issues.map { case (IssueInfo(issue, labels, milestone, priority, commentCount, commitId), status) => + @issues.map { case (IssueInfo(issue, labels, milestone, priority, commentCount, commitId, assignedUserNames), status) => @issue.userName/@issue.repositoryName ・ @@ -33,11 +33,9 @@ @label.labelName } - @* - @issue.assignedUserName.map { userName => + @assignedUserNames.map { userName => @helpers.avatar(userName, 20, tooltip = true) } - *@ @if(commentCount > 0){ @commentCount diff --git a/src/main/twirl/gitbucket/core/issues/listparts.scala.html b/src/main/twirl/gitbucket/core/issues/listparts.scala.html index 677cc0e18..2c369e7ea 100644 --- a/src/main/twirl/gitbucket/core/issues/listparts.scala.html +++ b/src/main/twirl/gitbucket/core/issues/listparts.scala.html @@ -206,7 +206,7 @@ } - @issues.map { case (IssueInfo(issue, labels, milestone, priority, commentCount, commitId), status) => + @issues.map { case (IssueInfo(issue, labels, milestone, priority, commentCount, commitId, assignedUserNames), status) => @if(isManageable){ @@ -230,11 +230,9 @@ @label.labelName } - @* - @issue.assignedUserName.map { userName => + @assignedUserNames.map { userName => @helpers.avatar(userName, 20, tooltip = true) } - *@ @if(commentCount > 0){ @commentCount diff --git a/src/main/twirl/gitbucket/core/issues/milestones/listparts.scala.html b/src/main/twirl/gitbucket/core/issues/milestones/listparts.scala.html index cdbff56ed..bfe3d6199 100644 --- a/src/main/twirl/gitbucket/core/issues/milestones/listparts.scala.html +++ b/src/main/twirl/gitbucket/core/issues/milestones/listparts.scala.html @@ -62,7 +62,7 @@ } - @issues.map { case (IssueInfo(issue, labels, milestone, priority, commentCount, commitId), status) => + @issues.map { case (IssueInfo(issue, labels, milestone, priority, commentCount, commitId, assignedUserNames), status) => @if(isManageable){ @@ -90,11 +90,9 @@ @label.labelName } - @* - @issue.assignedUserName.map { userName => + @assignedUserNames.map { userName => @helpers.avatar(userName, 20, tooltip = true) } - *@ @if(commentCount > 0){ @commentCount