From 68385e88b042976d2a7b1332b61c08ea1c39e83a Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Mon, 15 Feb 2016 06:46:54 -0500 Subject: [PATCH] Added limit arg to restrict count of non-prizewinners shown. --- lib/race.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/race.php b/lib/race.php index 83fd87d..8ecb653 100644 --- a/lib/race.php +++ b/lib/race.php @@ -746,6 +746,7 @@ $sort_method = $methods[$sort]; $format = (array_key_exists("format", $params)) ? $params["format"] : "ships"; $prize_filter = (array_key_exists("prizes", $params)) ? (int) $params["prizes"] : null; + $limit = (array_key_exists("limit", $params)) ? (int) $params["limit"] : null; $rq = new RaceQuery; if ($action) $rq->filterById($action); @@ -774,6 +775,7 @@ } $prizewinners = find_prizewinners($race, $entries, $prize_filter); uasort($entries, "Entry::$sort_method"); + if (! is_null($limit)) $limit = max(0, $limit - count($prizewinners["entries"])); } else { echo "

No entries.

\n"; @@ -831,6 +833,7 @@ $orange_fields = array('Best speed', 'Average speed', 'Fastest lap', 'Average lap', 'Award'); entry_header($sort, $format, $type, $blue_fields, $white_fields, $orange_fields); $n = $position = $rank = 1; + $shown = 0; $ship_entries = array(); $competitor_entries = array(); $competitor_hull_entries = array(); @@ -917,7 +920,10 @@ $r = (array_key_exists($name, $excluded_competitors)) ? 2 : 1; $excluded_competitors[$name] = 1; } - if ($prizewinners_only && ! $prize_name) continue; + if (! $prize_name) { + if ($prizewinners_only) continue; + if (! is_null($limit) && ++$shown > $limit) continue; + } show_entry($sort, $format, $entry, $allotted_time, $p, $r, $s, $n++, $type, $prize_name, count($blue_fields), count($white_fields)); if ($filter) $filtered_entries[] = $entry; } -- 2.7.4