Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-03-27 11:46:35 +0100
committerErich Eckner <git@eckner.net>2019-03-27 11:46:35 +0100
commit1c3eb159945e8f4c0f9006498c93cdcc19724cb9 (patch)
tree903fa8f2d09b477e93cd2002bcf9a570d9d7c96a
parentea8659f141fd14165af05bd9cd06bf95919447f2 (diff)
buildmaster/statistics.php: arch_filter_query() separated into lib/mysel.php
-rw-r--r--buildmaster/statistics.php30
-rw-r--r--lib/mysql.php11
2 files changed, 23 insertions, 18 deletions
diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php
index 05d06c6..7d706c6 100644
--- a/buildmaster/statistics.php
+++ b/buildmaster/statistics.php
@@ -2,29 +2,23 @@
require_once "../init.php";
require_once BASE . "/lib/mysql.php";
-if (array_key_exists("from",$_GET))
+if (array_key_exists("from", $_GET))
$min_time="from_base64(\"" . base64_encode("-".$_GET["from"]) . "\")";
else
$min_time="\"-7 00:00:00\"";
-if (array_key_exists("arch",$_GET)) {
- $arch_filter="`architectures`.`name` IN (\"\"";
- foreach (explode("&",$_SERVER["QUERY_STRING"]) as $param) {
- if (strpos($param,"arch=")!==0)
- continue;
- $arch_filter .= ",from_base64(\"" . base64_encode(substr($param,5)) . "\")";
- }
- $arch_filter .= ")";
- $combiner_left="";
- $combiner_right="";
- $grouper="";
- $joiner=" JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`";
+if (array_key_exists("arch", $_GET)) {
+ $arch_filter = arch_filter_query("architectures");
+ $combiner_left = "";
+ $combiner_right = "";
+ $grouper = "";
+ $joiner = " JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`";
} else {
- $arch_filter="1";
- $combiner_left="SUM(";
- $combiner_right=")";
- $grouper=" GROUP BY `statistics`.`date`";
- $joiner="";
+ $arch_filter = "1";
+ $combiner_left = "SUM(";
+ $combiner_right = ")";
+ $grouper = " GROUP BY `statistics`.`date`";
+ $joiner = "";
};
$column_list = array(
diff --git a/lib/mysql.php b/lib/mysql.php
index 2193ab1..ca683d8 100644
--- a/lib/mysql.php
+++ b/lib/mysql.php
@@ -87,3 +87,14 @@ function mysql_query_package_version($table) {
")" .
")";
}
+
+function arch_filter_query($table) {
+ $arch_filter="`" . $table . "`.`name` IN (\"\"";
+ foreach (explode("&", $_SERVER["QUERY_STRING"]) as $param) {
+ if (strpos($param, "arch=")!==0)
+ continue;
+ $arch_filter .= ",from_base64(\"" . base64_encode(substr($param,5)) . "\")";
+ }
+ $arch_filter .= ")";
+ return $arch_filter;
+}