Opened 4 years ago
Last modified 3 years ago
#2751 new enhancement
Update views/dataviews to use only some viability test types to calculate fields
| Reported by: | Cullen McGovern | Owned by: | Benjamin Haag |
|---|---|---|---|
| Priority: | medium | Milestone: | Next Release - Server |
| Component: | Database, Schema Changes | Version: | N/A |
| Severity: | Keywords: | ||
| Cc: | Database Engine: | N/A | |
| Operating System: | N/A |
Description
Only inventory_viability records with test_type_code of NULL, OR, MT, IR, RG, or XT should be used to calculate:
1) vc_inventory.pure_live_seed
2) nssl_inventory.estimated_shoots
NULL is included to maintain current behavior. Possibly accomplished with the following change to vc_inventory and an additional code group of COUNT_TEST:
WITH counted AS (
SELECT iv.*
FROM inventory_viability AS iv
LEFT JOIN code_value AS cv ON cv.value = iv.test_type_code
WHERE cv.group_name = 'COUNT_TEST' OR iv.test_type_code IS NULL
)
...
LEFT JOIN inventory_viability AS iv ON inventory_viability_id = (
SELECT MAX(inventory_viability_id)
FROM counted
WHERE inventory_id = i.inventory_id
AND tested_date = (
SELECT MAX(tested_date)
FROM counted
WHERE inventory_id = i.inventory_id
)
);
Then the members of the COUNT_TEST group would be OR, MT, IR, RG, and XT. This way, schema changes aren't needed to adjust the counted codes. I haven't tested this, but could if it seems like a good option.
Change History (2)
follow-up: 2 comment:1 by , 3 years ago
comment:2 by , 3 years ago
Replying to Benjamin Haag:
To clarify -- the intent is to change the SQL of specific dataviews? Which dataviews specifically?
The intent was possibly to change the SQL of the vc_inventory view -- that way dataviews don't need much changing, it's testable, etc. Does that seem like a good idea?
The SQL I put in the request is modified from the current vc_inventory. Should I give you the DDL for the complete, new, and improved vc_inventory?

To clarify -- the intent is to change the SQL of specific dataviews? Which dataviews specifically?