-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdescribe-page-or-template.sh
More file actions
74 lines (65 loc) · 2.41 KB
/
describe-page-or-template.sh
File metadata and controls
74 lines (65 loc) · 2.41 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Get the options
PageOrTemplateId=""
while getopts ":hi:" option; do
case $option in
i) # Enter an ID
PageOrTemplateId=$OPTARG;;
h) # Help message
echo "Usage: $0 -i page_or_template_id"
exit 0;;
\?) # Invalid option
echo "Error: Invalid option"
exit 1;;
esac
done
# Check if the name is at least 2 characters long
if [[ -z "$PageOrTemplateId" || ${#PageOrTemplateId} -lt 2 ]]; then
echo "Error: Page or Template id (-i argument) is required."
exit 1
fi
YELLOW='\033[0;33m'
RESET='\033[0m'
## Print Page Meta ---------------------
echo "${YELLOW}\n--- Page or Temoplate: #${PageOrTemplateId} ---\n${RESET}"
duckdb _tmpview.db "SELECT * FROM view_page_and_template WHERE pageOrTemplateId = '$PageOrTemplateId'"
## Print Chains ---------------------
echo "${YELLOW}\n--- All chains used in: #${PageOrTemplateId} ---\n${RESET}"
duckdb _tmpview.db "SELECT * FROM (
SELECT
chainName,
COUNT(DISTINCT featureName) as countOfTimesUsed
FROM view_rendering
INNER JOIN view_page_and_template ON view_page_and_template.published = view_rendering.renderingVersionId
AND view_page_and_template.pageOrTemplateId = '$PageOrTemplateId'
WHERE chainName != ''
GROUP BY chainName
)
ORDER BY chainName ASC"
## Print Features ---------------------
echo "${YELLOW}\n--- All features used in: #${PageOrTemplateId} ---\n${RESET}"
duckdb _tmpview.db "SELECT * FROM (
SELECT
featureName,
COUNT(DISTINCT CONCAT(COALESCE(chainName, ''), '|', layout, '|', COALESCE(contentService, ''))) as countOfTimesUsed
FROM view_rendering
INNER JOIN view_page_and_template ON view_page_and_template.published = view_rendering.renderingVersionId
AND view_page_and_template.pageOrTemplateId = '$PageOrTemplateId'
WHERE featureName != ''
GROUP BY featureName
)
ORDER BY featureName ASC"
## Print Content Sources ---------------------
echo "${YELLOW}\n--- Content sources used in: #${PageOrTemplateId} ---\n${RESET}"
duckdb _tmpview.db "SELECT * FROM (
SELECT
featureName,
contentService,
COUNT(DISTINCT CONCAT(COALESCE(chainName, ''), '|', layout)) as countOfTimesUsed
FROM view_rendering
INNER JOIN view_page_and_template ON view_page_and_template.published = view_rendering.renderingVersionId
AND view_page_and_template.pageOrTemplateId = '$PageOrTemplateId'
WHERE contentService != '' AND featureName != ''
GROUP BY contentService, featureName
)
ORDER BY featureName ASC"