Add assignee entry for the result of pull request related api
1 parent 0bd833a commit 884fc5318a2f016230b704b2f02dafea8effe9d0
@Yasuhiro Takagi Yasuhiro Takagi authored on 22 Jun 2017
Showing 6 changed files
View
16
src/main/scala/gitbucket/core/api/ApiPullRequest.scala
package gitbucket.core.api
 
import gitbucket.core.model.{Account, Issue, IssueComment, PullRequest}
import java.util.Date
import gitbucket.core.service.AccountService
import gitbucket.core.model.Profile._
import gitbucket.core.model.Profile.profile.blockingApi._
 
 
/**
* https://developer.github.com/v3/pulls/
merged_at: Option[Date],
merged_by: Option[ApiUser],
title: String,
body: String,
user: ApiUser) {
user: ApiUser,
assignee: Either[ApiUser,AnyRef]) extends AccountService {
val html_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}")
//val diff_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.diff")
//val patch_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.patch")
val url = ApiPath(s"${base.repo.url.path}/pulls/${number}")
headRepo: ApiRepository,
baseRepo: ApiRepository,
user: ApiUser,
mergedComment: Option[(IssueComment, Account)]
): ApiPullRequest =
)(implicit s: Session): ApiPullRequest =
ApiPullRequest(
number = issue.issueId,
updated_at = issue.updatedDate,
created_at = issue.registeredDate,
merged_at = mergedComment.map { case (comment, _) => comment.registeredDate },
merged_by = mergedComment.map { case (_, account) => ApiUser(account) },
title = issue.title,
body = issue.content.getOrElse(""),
user = user
user = user,
assignee = if (issue.assignedUserName == None) Right(null) else Left(ApiUser(getAccountByUserName(issue.assignedUserName.getOrElse("")).get))
)
 
case class Commit(
sha: String,
repo: ApiRepository)(baseOwner:String){
val label = if( baseOwner == repo.owner.login ){ ref }else{ s"${repo.owner.login}:${ref}" }
val user = repo.owner
}
 
def getAccountByUserName(userName: String, includeRemoved: Boolean = false)(implicit s: Session): Option[Account] =
Accounts filter(t => (t.userName === userName.bind) && (t.removed === false.bind, !includeRemoved)) firstOption
}
View
2
■■■
src/main/scala/gitbucket/core/api/JsonFormat.scala
{ case JString(s) => Try(parserISO.parseDateTime(s)).toOption.map(_.toDate).getOrElse(throw new MappingException("Can't convert " + s + " to Date")) },
{ case x: Date => JString(parserISO.print(new DateTime(x).withZone(DateTimeZone.UTC))) }
)
) + FieldSerializer[ApiUser]() +
FieldSerializer[ApiPullRequest]() +
FieldSerializer[ApiPullRequest](FieldSerializer.ignore("gitbucket$core$service$AccountService$$logger")) +
FieldSerializer[ApiRepository]() +
FieldSerializer[ApiCommitListItem.Parent]() +
FieldSerializer[ApiCommitListItem]() +
FieldSerializer[ApiCommitListItem.Commit]() +
View
4
src/main/scala/gitbucket/core/controller/ApiController.scala
// TODO: more api spec condition
val condition = IssueSearchCondition(request)
val baseOwner = getAccountByUserName(repository.owner).get
 
val issues: List[(Issue, Account, Int, PullRequest, Repository, Account)] =
val issues: List[(Issue, Account, Int, PullRequest, Repository, Account, Account)] =
searchPullRequestByApi(
condition = condition,
offset = (page - 1) * PullRequestLimit,
limit = PullRequestLimit,
repos = repository.owner -> repository.name
)
 
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner, assignee) =>
ApiPullRequest(
issue = issue,
pullRequest = pullRequest,
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
View
src/main/scala/gitbucket/core/service/IssuesService.scala
View
src/main/scala/gitbucket/core/service/WebHookService.scala
View
src/test/scala/gitbucket/core/api/JsonFormatSpec.scala