diff options
Diffstat (limited to 'includes/external/next')
-rw-r--r-- | includes/external/next/index.php | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/includes/external/next/index.php b/includes/external/next/index.php index 5e96fb7..f35a96f 100644 --- a/includes/external/next/index.php +++ b/includes/external/next/index.php @@ -69,16 +69,40 @@ $members = array_map(function ($i) { return $i["_system"] === "gdapd"; }))); -$requested = []; -foreach ([...$pairs, ...$pairs2] as $pair) { +$requested = []; foreach ([...$pairs, ...$pairs2] as $pair) { array_push($requested, ...$pair); -} +} $requested = array_unique($requested); + +usort($pairs2, function ($a, $b) use ($members) { + $times = []; + + foreach ($a as $id) { + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); + } + + $timeA = time() - min($times); + $times = []; + + foreach ($b as $id) { + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); + } + + $timeB = time() - min($times); + + if ($timeA < 5 || $timeB < 5) { + return -INF; + } else { + return $timeB - $timeA; + } +}); $pairsM = array_values($pairs2); + +$requested = array_map(function ($i) { return $i[0]; }, $pairsM); $fronters = array_map(function ($i) { return $i["id"]; }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"]); -$requested = array_values(array_filter(array_reverse(array_unique($requested)), function ($i) use ($fronters) { +$requested = array_values(array_filter(array_unique($requested), function ($i) use ($fronters) { return !in_array($i, $fronters); })); |