Publier Globinours 1.0.0-rc.3

This commit is contained in:
Alexandre NOEL 2026-09-03 12:39:15 +02:00
commit 9a2b4068da
325 changed files with 38230 additions and 20 deletions

View file

@ -0,0 +1,34 @@
DROP VIEW IF EXISTS v_animals_weight_alerts;
CREATE VIEW v_animals_weight_alerts AS
SELECT
a.id AS animal_id,
-- dernier poids
(
SELECT m.value
FROM measurements m
WHERE m.animal_id=a.id AND m.type='weight'
ORDER BY m.id DESC
LIMIT 1
) AS last_weight,
-- poids de référence ~30 jours avant : le plus récent <= J-30
(
SELECT m.value
FROM measurements m
WHERE m.animal_id=a.id AND m.type='weight'
AND date(m.measured_at) <= date('now','-30 day')
ORDER BY date(m.measured_at) DESC, m.id DESC
LIMIT 1
) AS w30_weight,
(
SELECT m.measured_at
FROM measurements m
WHERE m.animal_id=a.id AND m.type='weight'
AND date(m.measured_at) <= date('now','-30 day')
ORDER BY date(m.measured_at) DESC, m.id DESC
LIMIT 1
) AS w30_date
FROM animals a;