Browse Source

fix filtering for txn without tags at all

Daniel Sheffield 9 months ago
parent
commit
b8f91eb08a
1 changed files with 8 additions and 1 deletions
  1. 8 1
      sqlpage/transactions.sql

+ 8 - 1
sqlpage/transactions.sql

@@ -87,7 +87,7 @@ AND
     SELECT name FROM sqlpage_options WHERE type = 'end'
   )::date
 AND
-  t.id IN (
+  (t.id IN (
     SELECT
       transaction_id
     FROM tags_map
@@ -100,7 +100,14 @@ AND
       WHERE COALESCE(ot.selected, TRUE)
       AND ot.session = sqlpage.cookie('session')
     )
+  ) OR NOT EXISTS (
+      SELECT 1 
+      FROM sqlpage_options ot
+      WHERE ot.selected IS TRUE
+      AND ot.session = sqlpage.cookie('session')
+      AND ot.type = 'tag'
   )
+)
 ORDER BY ts DESC
 LIMIT 100);
 SELECT * FROM sqlpage_txn;