Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:cold_chain:dashboard [2022/05/26 03:48] – created Kat | en:cold_chain:dashboard [2022/05/31 04:37] (current) – Add telegram bot section Kat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Dashboard ====== | ====== Dashboard ====== | ||
- | These queries generally need to be set up by an administrator but have been included here as a reference | + | These queries generally need to be set up by an administrator but have been included here as a reference to demonstrate |
===== Sensor Graph ===== | ===== Sensor Graph ===== | ||
{{ : | {{ : | ||
+ | |||
+ | ==== Query ==== | ||
+ | < | ||
+ | WITH temp AS ( | ||
+ | SELECT | ||
+ | s.name, | ||
+ | CONCAT(TO_CHAR(date,' | ||
+ | tl.temperature | ||
+ | FROM temperature_log tl | ||
+ | JOIN sensor s ON tl.sensor_id = s.id | ||
+ | WHERE | ||
+ | CONCAT(TO_CHAR(date,' | ||
+ | ) | ||
+ | SELECT | ||
+ | $__time(log_datetime), | ||
+ | name, | ||
+ | temperature | ||
+ | FROM temp | ||
+ | ORDER BY log_datetime | ||
+ | </ | ||
===== Unacknowledged Breaches ===== | ===== Unacknowledged Breaches ===== | ||
{{ : | {{ : | ||
+ | |||
+ | ==== Query ==== | ||
+ | < | ||
+ | WITH breaches AS ( | ||
+ | SELECT | ||
+ | store_id, | ||
+ | location_id, | ||
+ | sensor_id, | ||
+ | s.name, | ||
+ | SUM(CASE WHEN type = ' | ||
+ | FROM temperature_breach | ||
+ | JOIN sensor s ON s.id = temperature_breach.sensor_id | ||
+ | WHERE CONCAT(TO_CHAR(start_date,' | ||
+ | AND acknowledged=' | ||
+ | GROUP BY store_id, location_id, | ||
+ | |||
+ | SELECT COUNT(*) FROM breaches | ||
+ | </ | ||
===== Batches affected ===== | ===== Batches affected ===== | ||
{{ : | {{ : | ||
+ | |||
+ | ==== Query ==== | ||
+ | < | ||
+ | WITH batch_count AS ( | ||
+ | SELECT | ||
+ | temperature_breach.store_id, | ||
+ | temperature_breach.location_id, | ||
+ | sensor_id, | ||
+ | s.name, | ||
+ | il.id, | ||
+ | SUM(CASE WHEN type = ' | ||
+ | FROM temperature_breach | ||
+ | JOIN sensor s ON s.id = temperature_breach.sensor_id | ||
+ | JOIN item_line il ON il.location_id = temperature_breach.location_id | ||
+ | WHERE CONCAT(TO_CHAR(start_date,' | ||
+ | AND acknowledged=' | ||
+ | GROUP BY temperature_breach.store_id, | ||
+ | |||
+ | ) | ||
+ | SELECT COUNT(*) FROM batch_count | ||
+ | </ | ||
===== Sensor battery life ===== | ===== Sensor battery life ===== | ||
{{ : | {{ : | ||
+ | |||
+ | ==== Query ==== | ||
+ | < | ||
+ | select | ||
+ | sum(CASE WHEN batterylevel < 20 then 1 else 0 end) as "Low battery", | ||
+ | sum(CASE WHEN batterylevel < 50 then 1 else 0 end) as " | ||
+ | sum(CASE WHEN batterylevel >= 50 then 1 else 0 end) as " | ||
+ | from sensor s | ||
+ | where s.is_active = true | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Telegram notifications for Cold Chain ===== | ||
+ | General instructions are here: https:// | ||
+ | |||
+ | But note that you need to invite your bot, not the bot father to the channel | ||
+ | |||
+ | Temperature logs rely on the alternate server in mSupply Desktop to be synced from the tablet to the server. If the alternate server is not running then no logs will be synced (and hence nothing will show on the Dashboard). | ||
+ | |||
+ | Can see if the alternate server process is really running by checking port 8081 in Windows cmd with netstat -ano | findstr :8081 | ||
+ | In this case process with ID 2188 is running ok. | ||
+ | {{ : | ||
+ |