aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorGravatar Victor Huesca <victor.huesca@bootlin.com>2019-08-13 09:08:21 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-08-13 21:51:59 +0200
commit757635e986e7428e20d38ac364d2d9462ef90cc9 (patch)
tree5673c60fd7d3a7f643078e36af3d42960b004729 /web
parentd760a648184c89c56d10647c538d5cb807321bbd (diff)
downloadbuildroot-test-757635e986e7428e20d38ac364d2d9462ef90cc9.tar.gz
buildroot-test-757635e986e7428e20d38ac364d2d9462ef90cc9.tar.bz2
web/funcs.inc.php: add support for filtering by date
This patch provides support for filtering by date in the 'bab_format_sql_filter' function. The date can be either a singe value -- in which case it is assumed as a 'from' date -- or an associative array with 'from' and/or 'to' keys defined. Signed-off-by: Victor Huesca <victor.huesca@bootlin.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'web')
-rw-r--r--web/funcs.inc.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/web/funcs.inc.php b/web/funcs.inc.php
index 9582e50..84f79a3 100644
--- a/web/funcs.inc.php
+++ b/web/funcs.inc.php
@@ -44,6 +44,16 @@ function bab_format_sql_filter($db, $filters)
return sprintf("%s like %s", $k, $db->quote_smart($v));
else if ($k == "status")
return sprintf("%s=%s", $k, $db->quote_smart($status_map[$v]));
+ elseif ($k == "date")
+ if (is_array($v)) {
+ if (isset($v['from'], $v['to']))
+ return sprintf("builddate between %s and %s", $db->quote_smart($v['from']), $db->quote_smart($v['to']));
+ else if (isset($v['to']))
+ return sprintf("builddate<=%s", $db->quote_smart($v['to']));
+ else
+ return sprintf("builddate>=%s", $db->quote_smart($v['from']));
+ } else // Assuming the date is a lower-bound
+ return sprintf("builddate>=%s", $db->quote_smart($v));
else
return sprintf("%s=%s", $k, $db->quote_smart($v));
},