-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.sql
59 lines (57 loc) · 1.97 KB
/
index.sql
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
select * from shell;
select
'alert' as component,
case
when (SELECT EXISTS (SELECT 1 FROM REPORTS WHERE DATEOFREPORT >= DATE('now', '-1 day'))) then 'Success'
else 'Error'
end as title,
case
when (SELECT EXISTS (SELECT 1 FROM REPORTS WHERE DATEOFREPORT >= DATE('now', '-1 day'))) then 'You had reported yesterday.'
else 'You hadn''t reported yesterday!!!'
end as description,
case
when (SELECT EXISTS (SELECT 1 FROM REPORTS WHERE DATEOFREPORT >= DATE('now', '-1 day'))) then 'check'
else 'alert-circle'
end as icon,
case
when (SELECT EXISTS (SELECT 1 FROM REPORTS WHERE DATEOFREPORT >= DATE('now', '-1 day'))) then 'green'
else 'red'
end as color;
select 'card' as component,
2 as columns;
select
'Last date reported:' as title,
case
when (SELECT DATEOFREPORT FROM REPORTS ORDER BY DATEOFREPORT DESC LIMIT 1) IS NULL then 'Not reported yet.'
else (SELECT DATEOFREPORT FROM REPORTS ORDER BY DATEOFREPORT DESC LIMIT 1) end
as description,
'24-hours' as icon,
'blue' as color;
select
'Reported hours/year (starting from 22/02/2024): ' as title,
(SELECT
SUM(
(strftime('%s', EXITTIME) - strftime('%s', ARRIVALTIME)) / 3600.0
) AS TotalReportedHours FROM REPORTS)
as description,
'report' as icon,
'yellow' as color;
select
'Open tickets' as title,
(select count(*) from tickets where ISCLOSED is FALSE) as description,
'mail-opened' as icon,
'orange' as color;
select
'Number of completed tickets' as title,
(select count(*) from tickets where ISCLOSED is TRUE) as description,
'number' as icon,
'green' as color;
select
'Total hours reported from last week' as title,
(select
SUM(
strftime('%s', EXITTIME) - strftime('%s', ARRIVALTIME)
) / 3600.0
FROM REPORTS
WHERE DATEOFREPORT >= DATE('now', '-7 days')
) as description;