Store diff JSON data into the database

This commit is contained in:
Naoki Takezoe
2018-04-27 08:55:14 +09:00
parent a720c6bee4
commit efe891a348
5 changed files with 19 additions and 10 deletions

View File

@@ -7,4 +7,8 @@
<addPrimaryKey constraintName="IDX_ACCOUNT_EXTRA_MAIL_ADDRESS_PK" tableName="ACCOUNT_EXTRA_MAIL_ADDRESS" columnNames="USER_NAME, EXTRA_MAIL_ADDRESS"/>
<addUniqueConstraint constraintName="IDX_ACCOUNT_EXTRA_MAIL_ADDRESS_1" tableName="ACCOUNT_EXTRA_MAIL_ADDRESS" columnNames="EXTRA_MAIL_ADDRESS"/>
<addColumn tableName="COMMIT_COMMENT">
<column name="DIFF" type="text" nullable="true" />
</addColumn>
</changeSet>

View File

@@ -562,7 +562,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
form.fileName,
form.oldLineNumber,
form.newLineNumber,
form.issueId
form.issueId,
form.diff
)
form.issueId match {
case Some(issueId) =>
@@ -613,11 +614,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
form.fileName,
form.oldLineNumber,
form.newLineNumber,
form.issueId
form.issueId,
form.diff
)
println(form.diff) // TODO store diff into the database
val comment = getCommitComment(repository.owner, repository.name, commentId.toString).get
form.issueId match {
case Some(issueId) =>

View File

@@ -54,6 +54,7 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile =>
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
val updatedDate = column[java.util.Date]("UPDATED_DATE")
val issueId = column[Option[Int]]("ISSUE_ID")
val diff = column[Option[String]]("DIFF")
def * =
(
userName,
@@ -67,7 +68,8 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile =>
newLine,
registeredDate,
updatedDate,
issueId
issueId,
diff
) <> (CommitComment.tupled, CommitComment.unapply)
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
@@ -86,7 +88,8 @@ case class CommitComment(
newLine: Option[Int],
registeredDate: java.util.Date,
updatedDate: java.util.Date,
issueId: Option[Int]
issueId: Option[Int],
diff: Option[String]
) extends Comment
case class CommitComments(

View File

@@ -31,7 +31,8 @@ trait CommitsService {
fileName: Option[String],
oldLine: Option[Int],
newLine: Option[Int],
issueId: Option[Int]
issueId: Option[Int],
diff: Option[String]
)(implicit s: Session): Int =
CommitComments returning CommitComments.map(_.commentId) insert CommitComment(
userName = owner,
@@ -44,7 +45,8 @@ trait CommitsService {
newLine = newLine,
registeredDate = currentDate,
updatedDate = currentDate,
issueId = issueId
issueId = issueId,
diff = diff
)
def updateCommitCommentPosition(commentId: Int, commitId: String, oldLine: Option[Int], newLine: Option[Int])(

View File

@@ -163,9 +163,9 @@ trait PullRequestService { self: IssuesService with CommitsService =>
// Collect comment positions
val positions = getCommitComments(pullreq.userName, pullreq.repositoryName, pullreq.commitIdTo, true)
.collect {
case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _) =>
case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _, _) =>
(file, commentId, Right(newLine))
case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _) =>
case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _, _) =>
(file, commentId, Left(oldLine))
}
.groupBy { case (file, _, _) => file }