recent.sql 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/theme.sql') AS properties;
  2. SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/Style.sql') AS properties;
  3. SET ":filter_config" = '[
  4. {"name": "expiry", "type": "hidden"},
  5. {"name": "value", "type": "hidden"},
  6. {"name": "type[]", "label": "Type",
  7. "type": "select", "dropdown": true,
  8. "multiple": true,
  9. "width": 3
  10. },
  11. {"name": "store[]", "create_new": false,
  12. "multiple": true,
  13. "width": 3
  14. },
  15. {"name": "expired", "label": "Show Expired",
  16. "type": "checkbox", "value": "true",
  17. "width": 2
  18. },
  19. {"name": "used", "label": "Show Used",
  20. "type": "checkbox", "value": "true",
  21. "width": 2
  22. }
  23. ]';
  24. SET ":validate" = 'Apply';
  25. SET ":action" = 'Apply';
  26. SET ":method" = 'get';
  27. SET ":autofill" = FALSE;
  28. SELECT 'dynamic' AS component, sqlpage.run_sql('code/form.sql') AS properties;
  29. SELECT 'list' AS component;
  30. SELECT COALESCE(type||' ','') || COALESCE(store||' ', '') || COALESCE(expiry, created) AS title
  31. , COALESCE(content->>'content'||' ', '') || COALESCE(content->>'type', '') AS description
  32. , '/code.sql?hash='||c.hash AS link
  33. FROM code c
  34. LEFT JOIN code_detail cd
  35. ON c.hash = cd.hash
  36. WHERE (
  37. cd.expiry IS NULL OR COALESCE($expired, 'false') = 'true' OR date(cd.expiry) > date(datetime(CURRENT_TIMESTAMP, 'localtime'))
  38. ) AND (
  39. cd.used IS NULL OR COALESCE($used||'', 'false') = 'true' OR COALESCE(cd.used||'','') = 'false'
  40. ) AND (
  41. CASE COALESCE($type, '')
  42. WHEN '' THEN TRUE
  43. ELSE $type IS NULL OR cd.type IN (SELECT value FROM json_each($type))
  44. END
  45. ) AND (
  46. CASE COALESCE($store, '')
  47. WHEN '' THEN TRUE
  48. ELSE $store IS NULL OR cd.store IN (SELECT value FROM json_each($store))
  49. END
  50. )
  51. ORDER BY expiry, created DESC, type, c.hash NULLS FIRST
  52. ;