Commit d41984f8 authored by Luke081515's avatar Luke081515

case zero

parent 9077100a
Pipeline #1854 passed with stages
in 1 minute and 58 seconds
......@@ -37,96 +37,122 @@ class GetUnrevStats extends Core {
$data = "action=query&format=json&list=unreviewedpages&rawcontinue=1&urlimit=max&urstart=" . urlencode($continue);
} while ($continue !== false);
$age[0] = 0;
for ($i = 0; isset($res[$i]); $i++) {
$temp = $this->getCreationDate($resTitle[$i]);
if ($temp === false) {
$age[$i] = 0;
} else {
$age[$i] = $temp;
if (!isset($res[0])) {
$today = strtotime($hour . ':00:00');
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"Average age\", 0);";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"Low average\", 0);";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"High average\", 0);";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (24h)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (48h)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (72h)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (5d)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (10d)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (15d)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (20d)\", 0, " . $today . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (25d)\", 0, " . $today . ");";
$this->DB->modify($sql);
} else {
for ($i = 0; isset($res[$i]); $i++) {
$temp = $this->getCreationDate($resTitle[$i]);
if ($temp === false) {
$age[$i] = 0;
} else {
$age[$i] = $temp;
}
}
$current = time();
$lagtotal = 0;
for ($i = 0; isset($age[$i]); $i++) {
$lagstamp[$i] = strtotime($age[$i]);
$lagdifference[$i] = $current - $lagstamp[$i];
$lagdifference[$i] = $lagdifference[$i] / 60 / 60 / 24;
$lagtotal = $lagtotal + $lagdifference[$i];
}
rsort($lagdifference);
$lagAverage = $lagtotal / count($lagdifference);
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"Average age\", " . $lagAverage . ");";
$this->DB->modify($sql);
$medium = count($lagdifference) / 2;
$lowerAverage = $medium - 1;
$lowerAverageLag = 0;
for ($i = $medium; isset($lagdifference[$i]); $i++) {
$lowerAverageLag = $lowerAverageLag + $lagdifference[$i];
}
$higherAverageLag = 0;
for ($i = 0; $i <= $lowerAverage; $i++) {
$higherAverageLag = $higherAverageLag + $lagdifference[$i];
}
$lowerAverageLag = $lowerAverageLag / $medium;
$higherAverageLag = $higherAverageLag / $medium;
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"Low average\", " . $lowerAverageLag . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"High average\", " . $higherAverageLag . ");";
$this->DB->modify($sql);
$i = 0;
while ($lagdifference[$i] > 1) {
$i++;
}
$hour = date('H');
$hour = $hour;
$today = strtotime($hour . ':00:00');
$stamp = strtotime('-1 day', $today);
$i--;
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (24h)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while ($lagdifference[$i] > 2) {
$i++;
}
$backlogPrevious = $i;
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (48h)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while ($lagdifference[$i] > 3) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (72h)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 5) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (5d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 10) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (10d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 15) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (15d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 20) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (20d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 25) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (25d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
}
$current = time();
$lagtotal = 0;
for ($i = 0; isset($age[$i]); $i++) {
$lagstamp[$i] = strtotime($age[$i]);
$lagdifference[$i] = $current - $lagstamp[$i];
$lagdifference[$i] = $lagdifference[$i] / 60 / 60 / 24;
$lagtotal = $lagtotal + $lagdifference[$i];
}
rsort($lagdifference);
$lagAverage = $lagtotal / count($lagdifference);
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"Average age\", " . $lagAverage . ");";
$this->DB->modify($sql);
$medium = count($lagdifference) / 2;
$lowerAverage = $medium - 1;
$lowerAverageLag = 0;
for ($i = $medium; isset($lagdifference[$i]); $i++) {
$lowerAverageLag = $lowerAverageLag + $lagdifference[$i];
}
$higherAverageLag = 0;
for ($i = 0; $i <= $lowerAverage; $i++) {
$higherAverageLag = $higherAverageLag + $lagdifference[$i];
}
$lowerAverageLag = $lowerAverageLag / $medium;
$higherAverageLag = $higherAverageLag / $medium;
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"Low average\", " . $lowerAverageLag . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO unrevage VALUES(CURRENT_TIMESTAMP, \"High average\", " . $higherAverageLag . ");";
$this->DB->modify($sql);
$i = 0;
while ($lagdifference[$i] > 1) {
$i++;
}
$hour = date('H');
$hour = $hour;
$today = strtotime($hour . ':00:00');
$stamp = strtotime('-1 day', $today);
$i--;
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (24h)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while ($lagdifference[$i] > 2) {
$i++;
}
$backlogPrevious = $i;
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (48h)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while ($lagdifference[$i] > 3) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (72h)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 5) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (5d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 10) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (10d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 15) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (15d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 20) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (20d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
$i = 0;
while (isset($lagdifference[$i]) && $lagdifference[$i] > 25) {
$i++;
}
$sql = "INSERT INTO unrevbacklog VALUES(CURRENT_TIMESTAMP, \"Old backlog (25d)\", " . $i . ", " . $today . ");";
$this->DB->modify($sql);
try {
$sql = "SELECT count FROM unrevbacklog WHERE recorded = " . $stamp . " AND type = \"Old backlog (24h)\";";
$result = $this->DB->query($sql);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment