1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<?php
global $ponies_raindrops;
global $ponies_cloudburst;
global $weekend;
$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true);
function ponies(string $system): array {
global $travelling;
global $weekend;
return array_map(function ($i) use ($system, $weekend) {
$switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-switches.json"), true);
$memberData = $i;
$i["_lastFronted"] = -1;
$i["_datesRaw"] = array_values(array_map(function ($i) {
return strtotime("1970-01-01T" . date("H:i:s", strtotime($i["timestamp"])) . ".000Z");
}, array_filter($switches, function ($item) use ($memberData) {
return in_array($memberData["id"], $item["members"]);
})));
$i["_datesValues"] = [
"night" => 0,
"morning" => 0,
"afternoon" => 0,
"evening" => 0
];
foreach ($i["_datesRaw"] as $date) {
if ($date < 16200 || $date >= 75600) $i["_datesValues"]["night"]++;
if ($date >= 61200 && $date < 75600) $i["_datesValues"]["evening"]++;
if ($date >= 39600 && $date < 61200) $i["_datesValues"]["afternoon"]++;
if ($date >= 16200 && $date < 39600) $i["_datesValues"]["morning"]++;
}
if (($i["_metadata"]["little"] === 2 || $i["_metadata"]["shared_memory"] < 2) && !$weekend) {
$i["_datesValues"]["morning"] = 0;
$i["_datesValues"]["afternoon"] = 0;
}
$i["_dates"] = array_values(array_filter(array_keys($i["_datesValues"]), function ($j) use ($i) {
return $i["_datesValues"][$j] > 0;
}));
uasort($i["_dates"], function ($a, $b) use ($i) {
return $i["_datesValues"][$b] - $i["_datesValues"][$a];
});
$i["_dates"] = array_values($i["_dates"]);
$id = $i["id"];
$fronters = array_map(function ($item) {
return $item["id"];
}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-fronters.json"), true)["members"]);
if (in_array($id, $fronters)) {
$i["_lastFronted"] = time();
} else {
$thisMember = array_filter($switches, function ($item) use ($memberData) {
return in_array($memberData["id"], $item["members"]);
});
$thisMember = array_values($thisMember);
$frontingEnd = null;
if (count($thisMember) > 0) {
$thisIndex = array_search($thisMember[0], $switches);
$frontingStart = $thisMember[0];
$frontingEnd = $switches[$thisIndex - 1];
}
if ($frontingEnd !== null && isset($frontingStart)) {
$i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
}
}
return $i;
}, array_values(array_filter(scoreOrderGlobal(), function ($i) use ($system, $travelling) {
return $i["_system"] === $system && (!in_array($i["id"], array_keys($travelling)) || !$travelling[$i["id"]]["travelling"]) && !isset($i["_metadata"]["median"]) && $i["name"] !== "unknown" && $i["name"] !== "fusion";
})));
}
$ponies_cloudburst = ponies("ynmuc");
uasort($ponies_cloudburst, function ($a, $b) {
return $b["_lastFronted"] - $a["_lastFronted"];
});
$ponies_cloudburst = array_filter($ponies_cloudburst, function ($i) { return $i["_lastFronted"] > 0; });
$ponies_raindrops = ponies("gdapd");
uasort($ponies_raindrops, function ($a, $b) {
return $b["_lastFronted"] - $a["_lastFronted"];
});
$ponies_raindrops = array_filter($ponies_raindrops, function ($i) { return $i["_lastFronted"] > 0; });
$ponies_cloudburst = array_reverse($ponies_cloudburst);
$ponies_raindrops = array_reverse($ponies_raindrops);
|