Update issue "updated" date when a comment is added or changed - fixes #111

Fri, 18 Dec 2020 16:09:20 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 18 Dec 2020 16:09:20 +0100
changeset 164
003b08bb3f25
parent 163
a5b9632729b6
child 165
b1fc8aed5969

Update issue "updated" date when a comment is added or changed - fixes #111

src/main/kotlin/de/uapcore/lightpit/dao/AbstractIssueDao.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/dao/postgres/PGIssueDao.kt file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/dao/AbstractIssueDao.kt	Fri Dec 18 15:54:39 2020 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/AbstractIssueDao.kt	Fri Dec 18 16:09:20 2020 +0100
@@ -74,6 +74,7 @@
     /**
      * Stores the specified comment in database.
      * This is an update-or-insert operation.
+     * The "updated" date of the corresponding issue is also updated.
      *
      * @param issue the issue to save the comment for
      * @param comment the comment to save
--- a/src/main/kotlin/de/uapcore/lightpit/dao/postgres/PGIssueDao.kt	Fri Dec 18 15:54:39 2020 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/postgres/PGIssueDao.kt	Fri Dec 18 16:09:20 2020 +0100
@@ -93,6 +93,10 @@
             "select * from lpit_issue_comment left join lpit_user using (userid) where issueid = ? order by created"
     )
 
+    private val updateIssueLastModified = connection.prepareStatement(
+        "update lpit_issue set updated = now() where issueid = ?"
+    );
+
     override fun mapResult(rs: ResultSet): Issue {
         val project = Project(rs.getInt("project"))
         project.name = rs.getString("projectname")
@@ -245,5 +249,7 @@
             setForeignKeyOrNull(insertComment, 3, comment.author, User::id)
             insertComment.execute()
         }
+        updateIssueLastModified.setInt(1, issue.id);
+        updateIssueLastModified.execute();
     }
 }
\ No newline at end of file

mercurial