mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Always set ModifiedTS including new packages
Set it equal to the SubmittedTS field, which will be our indication the package is new when we show the logo on the front page of the AUR. This results in the ability to remove the use of the unindexable GREATEST() function from the AUR code everywhere we had to use it before to handle the 0 timestamp case. Note that there is no race condition here in calling UNIX_TIMESTAMP() twice- it always returns the time at the beginning of statment execution: mysql> select unix_timestamp(), sleep(2), unix_timestamp(); +------------------+----------+------------------+ | unix_timestamp() | sleep(2) | unix_timestamp() | +------------------+----------+------------------+ | 1300851746 | 0 | 1300851746 | +------------------+----------+------------------+ 1 row in set (2.00 sec) Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
1128489bd0
commit
1f252eba64
5 changed files with 13 additions and 9 deletions
|
@ -1,6 +1,13 @@
|
||||||
Upgrading
|
Upgrading
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
From 1.8.1 to X.X.X
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
1. Update the modified package timestamp for new packages.
|
||||||
|
|
||||||
|
UPDATE Packages SET ModifiedTS = SubmittedTS WHERE ModifiedTS = 0;
|
||||||
|
|
||||||
From 1.8.0 to 1.8.1
|
From 1.8.0 to 1.8.1
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,7 @@ if ($_COOKIE["AURSID"]):
|
||||||
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
||||||
|
|
||||||
# This is a brand new package
|
# This is a brand new package
|
||||||
$q = sprintf("INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, SubmittedTS, SubmitterUID, MaintainerUID) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', UNIX_TIMESTAMP(), %d, %d)",
|
$q = sprintf("INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, SubmittedTS, ModifiedTS, SubmitterUID, MaintainerUID) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), %d, %d)",
|
||||||
mysql_real_escape_string($new_pkgbuild['pkgname']),
|
mysql_real_escape_string($new_pkgbuild['pkgname']),
|
||||||
mysql_real_escape_string($new_pkgbuild['license']),
|
mysql_real_escape_string($new_pkgbuild['license']),
|
||||||
mysql_real_escape_string($new_pkgbuild['pkgver']),
|
mysql_real_escape_string($new_pkgbuild['pkgver']),
|
||||||
|
|
|
@ -525,7 +525,7 @@ function pkg_search_page($SID="") {
|
||||||
$q_sort = "ORDER BY Maintainer ".$order.", Name ASC ";
|
$q_sort = "ORDER BY Maintainer ".$order.", Name ASC ";
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
$q_sort = "ORDER BY GREATEST(SubmittedTS,ModifiedTS) ".$order.", Name ASC ";
|
$q_sort = "ORDER BY ModifiedTS ".$order.", Name ASC ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,7 @@ function updates_table($dbh)
|
||||||
global $apc_prefix, $apc_ttl;
|
global $apc_prefix, $apc_ttl;
|
||||||
$key = $apc_prefix . 'recent_updates';
|
$key = $apc_prefix . 'recent_updates';
|
||||||
if(!(EXTENSION_LOADED_APC && ($newest_packages = apc_fetch($key)))) {
|
if(!(EXTENSION_LOADED_APC && ($newest_packages = apc_fetch($key)))) {
|
||||||
$q = 'SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY GREATEST(SubmittedTS,ModifiedTS) DESC LIMIT 0 , 10';
|
$q = 'SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY ModifiedTS DESC LIMIT 0 , 10';
|
||||||
$result = db_query($q, $dbh);
|
$result = db_query($q, $dbh);
|
||||||
|
|
||||||
$newest_packages = new ArrayObject();
|
$newest_packages = new ArrayObject();
|
||||||
|
@ -84,7 +84,7 @@ function general_stats_table($dbh)
|
||||||
$tu_count = db_cache_value($q, $dbh, $apc_prefix . 'tu_count');
|
$tu_count = db_cache_value($q, $dbh, $apc_prefix . 'tu_count');
|
||||||
|
|
||||||
$targstamp = intval(strtotime("-7 days"));
|
$targstamp = intval(strtotime("-7 days"));
|
||||||
$q = "SELECT count(*) from Packages WHERE (Packages.SubmittedTS >= $targstamp OR Packages.ModifiedTS >= $targstamp)";
|
$q = "SELECT count(*) from Packages WHERE Packages.ModifiedTS >= $targstamp";
|
||||||
$update_count = db_cache_value($q, $dbh, $apc_prefix . 'update_count');
|
$update_count = db_cache_value($q, $dbh, $apc_prefix . 'update_count');
|
||||||
|
|
||||||
include('stats/general_stats_table.php');
|
include('stats/general_stats_table.php');
|
||||||
|
|
|
@ -20,12 +20,10 @@
|
||||||
$mod_int = intval($row["ModifiedTS"]);
|
$mod_int = intval($row["ModifiedTS"]);
|
||||||
$sub_int = intval($row["SubmittedTS"]);
|
$sub_int = intval($row["SubmittedTS"]);
|
||||||
|
|
||||||
if ($mod_int != 0):
|
if ($mod_int == $sub_int):
|
||||||
$modstring = gmdate("r", $mod_int);
|
|
||||||
elseif ($sub_int != 0):
|
|
||||||
$modstring = '<img src="images/new.gif" alt="New!" /> ' . gmdate("r", $sub_int);
|
$modstring = '<img src="images/new.gif" alt="New!" /> ' . gmdate("r", $sub_int);
|
||||||
else:
|
else:
|
||||||
$modstring = '(unknown)';
|
$modstring = gmdate("r", $mod_int);
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -36,4 +34,3 @@ endif;
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue