summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2019-11-23 18:00:52 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2019-11-23 18:30:46 +0100
commit2422fb020b79b387ef667d146cf3e0dd7b1faebf (patch)
tree4cfc7ab7f9e81ee1f6aa49dc6106a0e6960c5797
parent4b97789bab8dae01987ffa4cdeb1e1257c95834f (diff)
downloadaur-2422fb020b79b387ef667d146cf3e0dd7b1faebf.tar.gz
aur-2422fb020b79b387ef667d146cf3e0dd7b1faebf.tar.xz
Store timestamp and user ID when closing requests
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rwxr-xr-xaurweb/git/serve.py10
-rw-r--r--schema/aur-schema.sql5
-rwxr-xr-xtest/t1200-git-serve.sh4
-rw-r--r--upgrading/4.9.0.txt6
-rw-r--r--web/lib/pkgreqfuncs.inc.php2
5 files changed, 21 insertions, 6 deletions
diff --git a/aurweb/git/serve.py b/aurweb/git/serve.py
index d43523c2..64d51b9e 100755
--- a/aurweb/git/serve.py
+++ b/aurweb/git/serve.py
@@ -207,18 +207,22 @@ def pkgreq_close(reqid, user, reason, comments, autoclose=False):
conn = aurweb.db.Connection()
if autoclose:
- userid = 0
+ userid = None
else:
cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", [user])
userid = cur.fetchone()[0]
if userid == 0:
raise aurweb.exceptions.InvalidUserException(user)
- conn.execute("UPDATE PackageRequests SET Status = ?, ClosureComment = ? " +
- "WHERE ID = ?", [status, comments, reqid])
+ now = int(time.time())
+ conn.execute("UPDATE PackageRequests SET Status = ?, ClosedTS = ?, " +
+ "ClosedUID = ?, ClosureComment = ? " +
+ "WHERE ID = ?", [status, now, userid, comments, reqid])
conn.commit()
conn.close()
+ if not userid:
+ userid = 0
subprocess.Popen((notify_cmd, 'request-close', str(userid), str(reqid),
reason)).wait()
diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql
index f05f40a3..fa991ba6 100644
--- a/schema/aur-schema.sql
+++ b/schema/aur-schema.sql
@@ -336,11 +336,14 @@ CREATE TABLE PackageRequests (
Comments TEXT NOT NULL,
ClosureComment TEXT NOT NULL,
RequestTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ ClosedTS BIGINT UNSIGNED NULL DEFAULT NULL,
+ ClosedUID INTEGER UNSIGNED NULL DEFAULT NULL,
Status TINYINT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (ID),
FOREIGN KEY (ReqTypeID) REFERENCES RequestTypes(ID) ON DELETE NO ACTION,
FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE SET NULL,
- FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE SET NULL
+ FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE SET NULL,
+ FOREIGN KEY (ClosedUID) REFERENCES Users(ID) ON DELETE SET NULL
) ENGINE = InnoDB;
CREATE INDEX RequestsUsersID ON PackageRequests (UsersID);
CREATE INDEX RequestsPackageBaseID ON PackageRequests (PackageBaseID);
diff --git a/test/t1200-git-serve.sh b/test/t1200-git-serve.sh
index 473065fc..e817b2cf 100755
--- a/test/t1200-git-serve.sh
+++ b/test/t1200-git-serve.sh
@@ -381,9 +381,9 @@ test_expect_success "Check whether package requests are closed when disowning."
grep "^Subject.*PRQ" sendmail.out >sendmail.parts &&
test_cmp sendmail.parts expected &&
cat <<-EOD >expected &&
- 1|2|3|foobar||4||The user user disowned the package.|0|2
+ 1|2||The user user disowned the package.
EOD
- echo "SELECT * FROM PackageRequests WHERE Status = 2;" | sqlite3 aur.db >actual &&
+ echo "SELECT ID, Status, ClosedUID, ClosureComment FROM PackageRequests WHERE ClosedTS > 0;" | sqlite3 aur.db >actual &&
test_cmp actual expected
'
diff --git a/upgrading/4.9.0.txt b/upgrading/4.9.0.txt
new file mode 100644
index 00000000..4c79283e
--- /dev/null
+++ b/upgrading/4.9.0.txt
@@ -0,0 +1,6 @@
+1. Add new columns to store the timestamp and UID when closing requests:
+
+----
+ALTER TABLE PackageRequests ADD COLUMN ClosedTS BIGINT UNSIGNED NULL DEFAULT NULL;
+ALTER TABLE PackageRequests ADD COLUMN ClosedUID INTEGER UNSIGNED NULL DEFAULT NULL;
+----
diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php
index 079df38c..7fce307c 100644
--- a/web/lib/pkgreqfuncs.inc.php
+++ b/web/lib/pkgreqfuncs.inc.php
@@ -247,6 +247,8 @@ function pkgreq_close($id, $reason, $comments, $auto_close=false) {
}
$q = "UPDATE PackageRequests SET Status = " . intval($status) . ", ";
+ $q.= "ClosedTS = " . strval(time()) . ", ";
+ $q.= "ClosedUID = " . ($uid == 0 ? "NULL" : intval($uid)) . ", ";
$q.= "ClosureComment = " . $dbh->quote($comments) . " ";
$q.= "WHERE ID = " . intval($id);
$dbh->exec($q);