﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	db_engine	os_version
2751	Update views/dataviews to use only some viability test types to calculate fields	Cullen McGovern	Benjamin Haag	"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."	enhancement	new	medium	Next Release - Server	Database, Schema Changes	N/A					N/A	N/A
