[aur-dev] [PATCH 1/2] Add a time stamp to package base votes
From: Lukas Fleischer <archlinux@cryptocrack.de> This can potentially be used to identify trending packages. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- schema/aur-schema.sql | 1 + upgrading/3.5.0.txt | 6 ++++++ web/lib/pkgbasefuncs.inc.php | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 08f87d8..afe19a1 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -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, diff --git a/upgrading/3.5.0.txt b/upgrading/3.5.0.txt index 152fc84..c21a48d 100644 --- a/upgrading/3.5.0.txt +++ b/upgrading/3.5.0.txt @@ -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; +---- diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 1ac0b47..df59a80 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -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 "; -- 2.1.2
From: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/voters.php | 7 ++++++- web/lib/pkgbasefuncs.inc.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/html/voters.php b/web/html/voters.php index b0753b9..a40a9a1 100644 --- a/web/html/voters.php +++ b/web/html/voters.php @@ -17,7 +17,12 @@ if (has_credential(CRED_PKGBASE_LIST_VOTERS)): <div class="boxbody"> <ul> <?php while (list($indx, $row) = each($votes)): ?> - <li><a href="<?= get_user_uri($row['Username']); ?>"><?= htmlspecialchars($row['Username']) ?></a></li> + <li> + <a href="<?= get_user_uri($row['Username']); ?>"><?= htmlspecialchars($row['Username']) ?></a> + <?php if ($row["VoteTS"] > 0): ?> + (<?= gmdate("Y-m-d H:i", intval($row["VoteTS"])) ?>) + <?php endif; ?> + </li> <?php endwhile; ?> </ul> </div> diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index df59a80..e1e4c1a 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -712,7 +712,7 @@ function pkgbase_vote ($base_ids, $action=true) { function pkgbase_votes_from_name($pkgbase_name) { $dbh = DB::connect(); - $q = "SELECT UsersID, Username, Name FROM PackageVotes "; + $q = "SELECT UsersID, Username, Name, VoteTS FROM PackageVotes "; $q.= "LEFT JOIN Users ON UsersID = Users.ID "; $q.= "LEFT JOIN PackageBases "; $q.= "ON PackageVotes.PackageBaseID = PackageBases.ID "; -- 2.1.2
participants (1)
-
archlinux@cryptocrack.de