Commit e9ebcc44 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Add a time stamp to package base votes



This can potentially be used to identify trending packages.
Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent c986ba0c
......@@ -249,6 +249,7 @@ CREATE TABLE PackageSources (
CREATE TABLE PackageVotes (
UsersID INTEGER UNSIGNED NOT NULL,
PackageBaseID INTEGER UNSIGNED NOT NULL,
VoteTS BIGINT UNSIGNED NULL DEFAULT NULL,
INDEX (UsersID),
INDEX (PackageBaseID),
FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE,
......
......@@ -5,3 +5,9 @@ ALTER TABLE PackageDepends ADD COLUMN DepArch VARCHAR(255) NULL DEFAULT NULL;
ALTER TABLE PackageRelations ADD COLUMN RelArch VARCHAR(255) NULL DEFAULT NULL;
ALTER TABLE PackageSources ADD COLUMN SourceArch VARCHAR(255) NULL DEFAULT NULL;
----
2. Add a time stamp column to the package votes table:
----
ALTER TABLE PackageVotes ADD COLUMN VoteTS BIGINT NULL DEFAULT NULL;
----
......@@ -667,12 +667,12 @@ function pkgbase_vote ($base_ids, $action=true) {
$first = 0;
$vote_ids = $pid;
if ($action) {
$vote_clauses = "($uid, $pid)";
$vote_clauses = "($uid, $pid, UNIX_TIMESTAMP())";
}
} else {
$vote_ids .= ", $pid";
if ($action) {
$vote_clauses .= ", ($uid, $pid)";
$vote_clauses .= ", ($uid, $pid, UNIX_TIMESTAMP())";
}
}
}
......@@ -686,7 +686,7 @@ function pkgbase_vote ($base_ids, $action=true) {
$dbh->exec($q);
if ($action) {
$q = "INSERT INTO PackageVotes (UsersID, PackageBaseID) VALUES ";
$q = "INSERT INTO PackageVotes (UsersID, PackageBaseID, VoteTS) VALUES ";
$q.= $vote_clauses;
} else {
$q = "DELETE FROM PackageVotes WHERE UsersID = $uid ";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment