This requires a bunch of changes since the types on these tables are much closer to the underlying types of the Fieldseeker data we are getting back from the API. I now need to use proper UUID types everywhere, which means I had to modify the bob gen config to consistently use google UUID, my UUID library of choice. I also had to add the organization_id to all the fieldseeker tables since we rely on them existing for some of our compound queries. There were some changes to the API type signatures to get things to build. I may yet regret those.
19 lines
646 B
SQL
19 lines
646 B
SQL
-- Code generated by BobGen psql v0.0.4-0.20251216163753-8e325b7c773a+dirty. DO NOT EDIT.
|
|
-- This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
-- TrapCountByLocationID
|
|
SELECT
|
|
td.globalid AS trapdata_globalid,
|
|
td.enddatetime AS trapdata_enddate,
|
|
COALESCE(SUM(sa.females), 0) AS total_females,
|
|
COALESCE(SUM(sa.males), 0) AS total_males,
|
|
COALESCE(SUM(sa.total), 0) AS total
|
|
FROM
|
|
fieldseeker.trapdata td
|
|
LEFT JOIN
|
|
fieldseeker.speciesabundance sa ON td.globalid = sa.trapdata_id
|
|
WHERE
|
|
td.organization_id = $1
|
|
AND td.loc_id IN ($2)
|
|
GROUP BY
|
|
td.globalid, td.loc_id, td.enddatetime;
|