From 4dab0e5a16ba9321f1fbb96a8f62999093769703 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Wed, 17 Jun 2026 17:19:45 +0000 Subject: [PATCH] Create a WATCHES.Type of sdb_ag_scan for feeding station groom scans --- db/schemas/sokwedb/indexes/create/watches.m4 | 6 ++++ db/schemas/sokwedb/indexes/drop/watches.m4 | 3 ++ doc/src/tables/events.m4 | 6 ++-- doc/src/tables/watches.m4 | 32 ++++++++++++++++++++ include/global_constants.m4 | 1 + 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/db/schemas/sokwedb/indexes/create/watches.m4 b/db/schemas/sokwedb/indexes/create/watches.m4 index db1cf36..708b096 100644 --- a/db/schemas/sokwedb/indexes/create/watches.m4 +++ b/db/schemas/sokwedb/indexes/create/watches.m4 @@ -42,6 +42,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS (date, focal) WHERE type = 'sdb_attendance'; +CREATE UNIQUE INDEX IF NOT EXISTS + "On WATCHES where (Type)=(sdb_ag_scan), Date must be unique" + ON watches + (date) + WHERE type = 'sdb_ag_scan'; + CREATE INDEX IF NOT EXISTS watches_date_focal_type ON watches (date, focal, type); CREATE INDEX IF NOT EXISTS watches_focal ON watches diff --git a/db/schemas/sokwedb/indexes/drop/watches.m4 b/db/schemas/sokwedb/indexes/drop/watches.m4 index 6714cef..b95ee41 100644 --- a/db/schemas/sokwedb/indexes/drop/watches.m4 +++ b/db/schemas/sokwedb/indexes/drop/watches.m4 @@ -31,6 +31,9 @@ DROP INDEX IF EXISTS DROP INDEX IF EXISTS "On WATCHES where (Type)=(sdb_attendance), Date + Focal must be unique"; +DROP INDEX IF EXISTS + "On WATCHES where (Type)=(sdb_ag_scan), Date must be unique"; + DROP INDEX IF EXISTS watches_date_focal_type; DROP INDEX IF EXISTS watches_focal; DROP INDEX IF EXISTS watches_commid; diff --git a/doc/src/tables/events.m4 b/doc/src/tables/events.m4 index 7bbb6e3..81f266f 100644 --- a/doc/src/tables/events.m4 +++ b/doc/src/tables/events.m4 @@ -156,10 +156,10 @@ The following table lists these rules and implications: .. _EVENTS_groom_scan_a_code: ``sdb_groom_scan_a`` (Attendance SCAN interval Groomings) - The EVENTS row must be associated with a record of attendance at - the feeding station. + The EVENTS row must be associated with a interval scan for grooming + done at the feeding station. This means the |EVENTS.WID| column must reference a |WATCHES| row - with a |WATCHES|.\ |WATCHES.Type| value of ``sdb_attendance``. + with a |WATCHES|.\ |WATCHES.Type| value of ``sdb_ag_scan``. The |ROLES| rows related to the event, the rows with a |ROLES|.\ |ROLES.EID| value equal to the EVENTS.\ |EVENTS.EID| value, diff --git a/doc/src/tables/watches.m4 b/doc/src/tables/watches.m4 index 9e4b02b..307c993 100644 --- a/doc/src/tables/watches.m4 +++ b/doc/src/tables/watches.m4 @@ -152,6 +152,38 @@ The available |WATCHES.Type| values are: This means, the combination of |WATCHES.Type|, |WATCHES.Focal| and |WATCHES.Date| must be unique. +``sdb_ag_scan`` (Attendance Groom scan) + + Each row records a date on which groomings were scanned for on + periodic intervals. + There is one WATCHES row of this type per date. + + The expectation is that the individual associated *with* *the* + *scan* (not the grooming), the individual recorded in the + |WATCHES.Focal| column, will always be ``sdb_unk``. + The system will issue a warning when the associated individual is + not ``sdb_unk``, when |WATCHES.Focal| is not ``sdb_unk``. + + The |WATCHES.Focal| column contains little information that is + useful, because feeding station groom scans were not associated + with any type of observation that specifically targeted a + particular individual. + + The |WATCHES.CommID| column contains the code for the community + recorded at along with the pantgrunt; the |COMM_IDS|.\ + |COMM_IDS.CommID| of the community. + This is not necessarily the community the individual(s) involved in + the grooming is(are) a member of, although it usually is. + + There may only be one row on WATCHES per day to record interval + scans for grooming at the feeding station. + This means, the combination of |WATCHES.Type| and |WATCHES.Date| + must be unique. + When multiple individuals were found to be grooming, during + interval scans for grooming conducted at the feeding station on any + given day, the one WATCHES row has multiple related rows on the + |EVENTS| table. + ``sdb_location`` (Location) Each row represents a date on which an individual was spatially located. diff --git a/include/global_constants.m4 b/include/global_constants.m4 index b03fba6..6a31384 100644 --- a/include/global_constants.m4 +++ b/include/global_constants.m4 @@ -196,6 +196,7 @@ dnl dnl The WATCHES.Type values define(`sdb_attendance', `A') define(`sdb_follow', `F') +define(`sdb_ag_scan', `G') define(`sdb_location', `L') define(`sdb_pantgrunt', `P') -- 2.34.1