From c8b3baa717046717f1561bf6344c6ffd6201dd7b Mon Sep 17 00:00:00 2001
From: Fabian Schindler <fabian.schindler.strauss@gmail.com>
Date: Sun, 29 Mar 2020 19:03:56 +0200
Subject: [PATCH] Using view to simplify queries

---
 config/vhr18_mapcache-dev.xml | 48 +++++++++++++++++------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/config/vhr18_mapcache-dev.xml b/config/vhr18_mapcache-dev.xml
index e175591a..ee5ae0cf 100644
--- a/config/vhr18_mapcache-dev.xml
+++ b/config/vhr18_mapcache-dev.xml
@@ -129,8 +129,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -151,8 +151,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -173,8 +173,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -195,8 +195,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -274,8 +274,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -296,8 +296,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -318,8 +318,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -340,8 +340,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_1' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_1' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -443,8 +443,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -465,8 +465,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -487,8 +487,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
@@ -509,8 +509,8 @@
       <subdimensions_read_only>false</subdimensions_read_only>
       <dimension type="postgresql" name="time" default="2017/2019" time="true" unit="ISO8601">
         <connection>host={{DB_HOST}} user={{DB_USER}} password={{DB_PW}} dbname={{DB_NAME}} port={{DB_PORT}}</connection>
-        <list_query>SELECT CONCAT(to_char(MIN(T5."begin_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(T5."end_time"),'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE "coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3';</list_query>
-        <validate_query>SELECT * FROM (SELECT CONCAT(to_char(T5."begin_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(T5."end_time",'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) AS "interval" FROM "coverages_product" INNER JOIN "coverages_product_collections" ON ("coverages_product"."eoobject_ptr_id" = "coverages_product_collections"."product_id") INNER JOIN "coverages_collection" ON ("coverages_product_collections"."collection_id" = "coverages_collection"."eoobject_ptr_id") INNER JOIN "coverages_eoobject" ON ("coverages_collection"."eoobject_ptr_id" = "coverages_eoobject"."id") INNER JOIN "coverages_eoobject" T5 ON ("coverages_product"."eoobject_ptr_id" = T5."id") WHERE ("coverages_eoobject"."identifier" = 'VHR_IMAGE_2018_Level_3' AND ((T5."begin_time" &lt; to_timestamp(:end_timestamp) AND T5."end_time" &gt; to_timestamp(:start_timestamp)) or (T5."begin_time" = T5."end_time" AND T5."begin_time" &lt;= to_timestamp(:end_timestamp) AND T5."end_time" &gt;= to_timestamp(:start_timestamp)))) AND T5."footprint" &amp;&amp; ST_MakeEnvelope(:minx,:miny,:maxx,:maxy,4326) ORDER BY T5."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
+        <list_query>SELECT CONCAT(to_char(MIN(mapcache_items."begin_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'), CONCAT('/', to_char(MAX(mapcache_items."end_time"), 'YYYY-MM-DD"T"HH24:MI:SS"Z"'))) FROM mapcache_items WHERE mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3';</list_query>
+        <validate_query>SELECT * FROM (SELECT interval FROM mapcache_items WHERE (mapcache_items."collection" = 'VHR_IMAGE_2018_Level_3' AND ((mapcache_items."begin_time" &lt; to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt; to_timestamp(:start_timestamp)) or (mapcache_items."begin_time" = mapcache_items."end_time" AND mapcache_items."begin_time" &lt;= to_timestamp(:end_timestamp) AND mapcache_items."end_time" &gt;= to_timestamp(:start_timestamp)))) AND mapcache_items."footprint" &amp;&amp; ST_MakeEnvelope(:minx, :miny, :maxx, :maxy, 4326) ORDER BY mapcache_items."end_time" DESC LIMIT 20) AS sub ORDER BY interval ASC;</validate_query>
       </dimension>
     </dimensions>
   </tileset>
-- 
GitLab