[aur-dev] [PATCH 1/2] Add a parameter to skip old requests to pkgreq_list()
Allow for hiding requests which were opened before a given time stamp. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/pkgreqfuncs.inc.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 7dcab13..774ebe7 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -20,10 +20,11 @@ function pkgreq_count() { * @param int $offset The index of the first request to return * @param int $limit The maximum number of requests to return * @param int $uid Only return packages affecting the given user + * @param int $from Do not return packages older than the given date * - * @return array List of pacakge requests with details + * @return array List of package requests with details */ -function pkgreq_list($offset, $limit, $uid=false) { +function pkgreq_list($offset, $limit, $uid=false, $from=false) { $dbh = DB::connect(); $q = "SELECT PackageRequests.ID, "; @@ -37,9 +38,15 @@ function pkgreq_list($offset, $limit, $uid=false) { $q.= "RequestTypes.ID = PackageRequests.ReqTypeID "; $q.= "INNER JOIN Users ON Users.ID = PackageRequests.UsersID "; - if ($uid) { - $q.= "WHERE PackageRequests.UsersID = " . intval($uid). " "; - $q.= "OR Users.ID = " . intval($uid) . " "; + if ($uid || $from) { + $q.= "WHERE "; + if ($uid) { + $q.= "(PackageRequests.UsersID = " . intval($uid). " "; + $q.= "OR Users.ID = " . intval($uid) . ") AND "; + } + if ($from) { + $q.= "RequestTS >= " . intval($from). " "; + } } $q.= "ORDER BY Open DESC, RequestTS DESC "; -- 2.11.1
Only show package requests created less than 6 months ago on the dashboard. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- conf/config.proto | 1 + web/html/home.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/config.proto b/conf/config.proto index 01a907a..df10b99 100644 --- a/conf/config.proto +++ b/conf/config.proto @@ -25,6 +25,7 @@ max_rpc_results = 5000 max_depends = 1000 aur_request_ml = aur-requests@archlinux.org request_idle_time = 1209600 +request_archive_time = 15552000 auto_orphan_age = 15552000 auto_delete_age = 86400 source_file_uri = https://aur.archlinux.org/cgit/aur.git/tree/%s?h=%s diff --git a/web/html/home.php b/web/html/home.php index ee7caf7..2675491 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -35,7 +35,9 @@ if (isset($_COOKIE["AURSID"])) { ?> <h3><?= __("My Requests"); ?></h3> <?php - $results = pkgreq_list(0, 50, uid_from_sid($_COOKIE["AURSID"])); + $archive_time = config_get_int('options', 'request_archive_time'); + $from = time() - $archive_time; + $results = pkgreq_list(0, 50, uid_from_sid($_COOKIE["AURSID"]), $from); $show_headers = false; include('pkgreq_results.php'); ?> -- 2.11.1
participants (1)
-
Lukas Fleischer