ices-eg / wg_WGEEL

Joint EIFAAC/ICES/GFCM Working Group on Eels
http://ices.dk/community/groups/Pages/WGEEL.aspx
5 stars 16 forks source link

Add check in shiny integration that aquaculture values can only be provided as kg #93

Closed LBeaulaton closed 2 years ago

elfunesto commented 4 years ago

In loading_functions, we have

    #  eel_typ_id should be q_aqua_kg
    data_error = rbind(data_error,  check_values(dataset=data_xls,
            column="eel_typ_name",
            country=country,
            values=c("q_aqua_kg")))

to highlight such problem. Do we need to add a constraint in the db?

elfunesto commented 4 years ago

Here is a solution to implement a check in the db: first we change the type of a value from Spain (check with Esti first) and then remove data that were aquaculture for restocking, and finally add a check on eel_typ_id!=12

--to be checked with Esti, I think that the type is aquaculture_kg not aquaculture_number (anyway, it is declared at the emu scale not at the country scale so no valid)
update datawg.t_eelstock_eel set eel_typ_id =11, eel_qal_id=20,
eel_comment ='type corrected in 2020' where eel_typ_id =12  and eel_year=2014   and eel_emu_nameshort ='ES_Vale' and eel_lfs_code='OG' and eel_hty_code='MO'
--other data correspond to restocking so should not be in the db
delete from datawg.t_eelstock_eel where eel_typ_id=12;

ALTER TABLE datawg.t_eelstock_eel ADD CONSTRAINT ck_removed_typid CHECK (eel_typ_id != 12);