-
-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathstories.sql
More file actions
52 lines (47 loc) · 1.42 KB
/
stories.sql
File metadata and controls
52 lines (47 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
SELECT 'http_header' AS component,
'no-store, no-cache, must-revalidate, max-age=0' AS "Cache-Control",
'no-cache' AS "pragma",
'0' AS "expires";
SELECT 'dynamic' AS component, json_patch(json_extract(properties, '$[0]'), json_object(
'title', 'SQLPage Success Stories'
)) AS properties
FROM example WHERE component = 'shell' LIMIT 1;
SET TEXT_MAX_LENGTH = 300;
SELECT
'alert' AS component,
CONCAT('You have selected the "', $filter, '" filter.') AS title,
'filter' AS icon,
'teal' AS color,
TRUE AS dismissible,
'[Click here to deactivate it.](stories)' AS description_md
WHERE $id IS NULL
AND $filter IS NOT NULL
SELECT
'stories' AS component,
$filter AS filter,
id,
title,
publication_date,
tags,
CASE
WHEN LENGTH(contents_md) > CAST($EXT_MAX_LENGTH AS INTEGER) THEN SUBSTR(contents_md, 1, CAST($TEXT_MAX_LENGTH AS INTEGER)) || '...'
ELSE contents_md
END as truncated_contents
FROM stories
WHERE
$id IS NULL
AND ($filter IS NULL OR EXISTS (SELECT 1 FROM json_each(tags) WHERE value LIKE $filter COLLATE NOCASE))
ORDER BY publication_date DESC;
SELECT
'story' AS component,
$filter AS filter,
id,
title,
publication_date,
contents_md,
optional_contents_md,
image,
website,
git_repository
FROM stories
WHERE id = $id;