Explorar el Código

fix tags page and page titles

Daniel Sheffield hace 9 meses
padre
commit
b6a8ff6689
Se han modificado 6 ficheros con 51 adiciones y 20 borrados
  1. 6 2
      sqlpage/categories.sql
  2. 6 2
      sqlpage/groups.sql
  3. 0 4
      sqlpage/nav.sql
  4. 6 1
      sqlpage/products.sql
  5. 28 11
      sqlpage/tags.sql
  6. 5 0
      sqlpage/transactions.sql

+ 6 - 2
sqlpage/categories.sql

@@ -3,6 +3,11 @@ SELECT
   sqlpage.run_sql('cookie.sql') AS properties
 ;
 
+SELECT 'shell' AS component,
+  'dark' AS theme,
+  'Categories' AS title
+;
+
 SELECT
   'dynamic' as component,
   sqlpage.run_sql('nav.sql') AS properties
@@ -35,8 +40,7 @@ JOIN groups g ON c.group_id = g.id
 JOIN sqlpage_options op ON op.type = 'product' AND p.name = op.name
 JOIN sqlpage_options oc ON oc.type = 'category' AND c.name = oc.name
 JOIN sqlpage_options og ON og.type = 'group' AND g.name = og.name
-WHERE COALESCE(op.selected, oc.selected, og.selected, TRUE)
-AND
+WHERE
   COALESCE(op.selected, oc.selected, og.selected, TRUE)
 AND
   op.session = sqlpage.cookie('session')

+ 6 - 2
sqlpage/groups.sql

@@ -3,6 +3,11 @@ SELECT
   sqlpage.run_sql('cookie.sql') AS properties
 ;
 
+SELECT 'shell' AS component,
+  'dark' AS theme,
+  'Groups' AS title
+;
+
 SELECT
   'dynamic' as component,
   sqlpage.run_sql('nav.sql') AS properties
@@ -35,8 +40,7 @@ JOIN groups g ON c.group_id = g.id
 JOIN sqlpage_options op ON op.type = 'product' AND p.name = op.name
 JOIN sqlpage_options oc ON oc.type = 'category' AND c.name = oc.name
 JOIN sqlpage_options og ON og.type = 'group' AND g.name = og.name
-WHERE COALESCE(op.selected, oc.selected, og.selected, TRUE)
-AND
+WHERE
   COALESCE(op.selected, oc.selected, og.selected, TRUE)
 AND
   op.session = sqlpage.cookie('session')

+ 0 - 4
sqlpage/nav.sql

@@ -1,7 +1,3 @@
-SELECT 'shell' AS component,
-  'dark' AS theme,
-  COALESCE($tab, 'Transactions') AS title
-;
 CREATE TABLE IF NOT EXISTS sqlpage_options(
   session text,
   "type" text,

+ 6 - 1
sqlpage/products.sql

@@ -3,6 +3,11 @@ SELECT
   sqlpage.run_sql('cookie.sql') AS properties
 ;
 
+SELECT 'shell' AS component,
+  'dark' AS theme,
+  'Products' AS title
+;
+
 SELECT
   'dynamic' as component,
   sqlpage.run_sql('nav.sql') AS properties
@@ -35,7 +40,7 @@ JOIN groups g ON c.group_id = g.id
 JOIN sqlpage_options op ON op.type = 'product' AND p.name = op.name
 JOIN sqlpage_options oc ON oc.type = 'category' AND c.name = oc.name
 JOIN sqlpage_options og ON og.type = 'group' AND g.name = og.name
-AND
+WHERE
   COALESCE(op.selected, oc.selected, og.selected, TRUE)
 AND
   op.session = sqlpage.cookie('session')

+ 28 - 11
sqlpage/tags.sql

@@ -3,6 +3,11 @@ SELECT
   sqlpage.run_sql('cookie.sql') AS properties
 ;
 
+SELECT 'shell' AS component,
+  'dark' AS theme,
+  'Tags' AS title
+;
+
 SELECT
   'dynamic' as component,
   sqlpage.run_sql('nav.sql') AS properties
@@ -19,22 +24,37 @@ SELECT
 DROP TABLE IF EXISTS sqlpage_tags;
 CREATE TEMPORARY TABLE IF NOT EXISTS sqlpage_tags AS (
 SELECT * FROM (SELECT count(DISTINCT txn.id) AS "Uses", tg.name AS "Name"
-	FROM tags tg
-	JOIN tags_map tm ON tg.id = tm.tag_id
-	JOIN transactions txn ON txn.id = tm.transaction_id
-	WHERE {where}
-	GROUP BY tg.name
-	ORDER BY 1 DESC, 2) q
+FROM tags tg
+JOIN tags_map tm ON tg.id = tm.tag_id
+JOIN transactions txn ON txn.id = tm.transaction_id
+JOIN products p ON p.id = txn.product_id
+JOIN categories c ON p.category_id = c.id
+JOIN groups g ON c.group_id = g.id
+JOIN sqlpage_options op ON op.type = 'product' AND p.name = op.name
+JOIN sqlpage_options oc ON oc.type = 'category' AND c.name = oc.name
+JOIN sqlpage_options og ON og.type = 'group' AND g.name = og.name
+WHERE 
+  COALESCE(op.selected, oc.selected, og.selected, TRUE)
+AND
+  op.session = sqlpage.cookie('session')
+AND
+  oc.session = sqlpage.cookie('session')
+AND
+  og.session = sqlpage.cookie('session')
+GROUP BY tg.name
+ORDER BY 1 DESC, 2) q
 UNION ALL
 SELECT count(DISTINCT txn.id) AS "Uses", count(DISTINCT tg.name)||'' AS "Name"
 FROM tags tg
 JOIN tags_map tm ON tg.id = tm.tag_id
 JOIN transactions txn ON txn.id = tm.transaction_id
+JOIN products p ON p.id = txn.product_id
+JOIN categories c ON p.category_id = c.id
+JOIN groups g ON c.group_id = g.id
 JOIN sqlpage_options op ON op.type = 'product' AND p.name = op.name
 JOIN sqlpage_options oc ON oc.type = 'category' AND c.name = oc.name
 JOIN sqlpage_options og ON og.type = 'group' AND g.name = og.name
-WHERE COALESCE(op.selected, oc.selected, og.selected, TRUE)
-AND
+WHERE
   COALESCE(op.selected, oc.selected, og.selected, TRUE)
 AND
   op.session = sqlpage.cookie('session')
@@ -42,9 +62,6 @@ AND
   oc.session = sqlpage.cookie('session')
 AND
   og.session = sqlpage.cookie('session')
-GROUP BY ROLLUP (g.name, c.name, p.name)
-ORDER BY product, category, "group") q
-WHERE q.category IS NULL
 );
 SELECT * FROM sqlpage_tags;
 

+ 5 - 0
sqlpage/transactions.sql

@@ -3,6 +3,11 @@ SELECT
   sqlpage.run_sql('cookie.sql') AS properties
 ;
 
+SELECT 'shell' AS component,
+  'dark' AS theme,
+  'Transactions' AS title
+;
+
 SELECT
   'dynamic' as component,
   sqlpage.run_sql('nav.sql') AS properties