summaryrefslogtreecommitdiff
path: root/includes/external/next/index.php
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2024-03-29 22:05:35 +0100
committerRaindropsSys <raindrops@equestria.dev>2024-03-29 22:05:35 +0100
commit5860551daa0f60103ad24e93da29f401a653f144 (patch)
tree9ad97e04152a6edc11d5096c87880978df39086a /includes/external/next/index.php
parenta51979ad60074db84af78a06d30fcb888ccb0b03 (diff)
downloadpluralconnect-5860551daa0f60103ad24e93da29f401a653f144.tar.gz
pluralconnect-5860551daa0f60103ad24e93da29f401a653f144.tar.bz2
pluralconnect-5860551daa0f60103ad24e93da29f401a653f144.zip
Updated 20 files, added 6 files, deleted 144 files and renamed .idea/ponycule.iml (automated)
Diffstat (limited to 'includes/external/next/index.php')
-rw-r--r--includes/external/next/index.php32
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);
}));