diff -r ea6181255423 -r 671c1c8fbf1c src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Sat Jul 22 15:07:23 2023 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Sat Jul 22 22:32:04 2023 +0200 @@ -26,6 +26,7 @@ package de.uapcore.lightpit.dao import de.uapcore.lightpit.entities.* +import de.uapcore.lightpit.types.CommitRef import de.uapcore.lightpit.types.IssueHistoryType import de.uapcore.lightpit.types.RelationType import de.uapcore.lightpit.types.WebColor @@ -358,7 +359,7 @@ //language=SQL private val projectQuery = """ - select projectid, name, node, ordinal, description, repourl, + select projectid, name, node, ordinal, description, vcs, repourl, userid, username, lastname, givenname, mail from lpit_project left join lpit_user owner on lpit_project.owner = owner.userid @@ -370,6 +371,7 @@ node = getString("node") ordinal = getInt("ordinal") description = getString("description") + vcs = getEnum("vcs") repoUrl = getString("repourl") owner = extractOptionalUser() } @@ -381,6 +383,7 @@ setStringSafe(i++, node) setInt(i++, ordinal) setStringOrNull(i++, description) + setEnum(i++, vcs) setStringOrNull(i++, repoUrl) setIntOrNull(i++, owner?.id) } @@ -405,14 +408,14 @@ } override fun insertProject(project: Project) { - withStatement("insert into lpit_project (name, node, ordinal, description, repourl, owner) values (?, ?, ?, ?, ?, ?)") { + withStatement("insert into lpit_project (name, node, ordinal, description, vcs, repourl, owner) values (?, ?, ?, ?, ?::vcstype, ?, ?)") { setProject(1, project) executeUpdate() } } override fun updateProject(project: Project) { - withStatement("update lpit_project set name = ?, node = ?, ordinal = ?, description = ?, repourl = ?, owner = ? where projectid = ?") { + withStatement("update lpit_project set name = ?, node = ?, ordinal = ?, description = ?, vcs = ?::vcstype, repourl = ?, owner = ? where projectid = ?") { val col = setProject(1, project) setInt(col, project.id) executeUpdate() @@ -471,6 +474,17 @@ } } + override fun mergeCommitRefs(refs: List) { + withStatement("insert into lpit_commit_ref (issueid, commit_hash, commit_brief) values (?,?,?) on conflict do nothing") { + refs.forEach { ref -> + setInt(1, ref.issueId) + setString(2, ref.hash) + setString(3, ref.message) + executeUpdate() + } + } + } + // // @@ -636,6 +650,18 @@ } } + override fun listCommitRefs(issue: Issue): List = + withStatement("select commit_hash, commit_brief from lpit_commit_ref where issueid = ?") { + setInt(1, issue.id) + queryAll { + CommitRef( + issueId = issue.id, + hash = it.getString("commit_hash"), + message = it.getString("commit_brief") + ) + } + } + // //