app/classes/commodity.js
// Remove any measures that are not financial or are not relevant to my country
Remove any measures that are not financial or are not relevant to my country
Remove any measures that are not financial or are not relevant to my country
remove_irrelevant_measures(measure_types) {
        var i;
        this.measures.forEach(m => {
            m.irrelevant_additional_code = false;
            this.measure_types.forEach(mt => {
                if (mt.id == m.measure_type_id) {
                    m.financial = mt.financial;
                    m.measure_type_series_id = mt.measure_type_series_id;
                }
            });
            var barred_codes = ['2551', '2552'];
            var additional_code_id;
            if (m.additional_code != null) {
                additional_code_id = m.additional_code.code
            } else {
                additional_code_id = "";
            }
            if (barred_codes.includes(additional_code_id)) {
                m.irrelevant_additional_code = true;
                console.log("Splicing " + additional_code_id);
            }
            if ((m.geographical_area_id == this.origin) || (m.geographical_area.member_strings.includes(this.origin))) {
                m.relevant = true;
            }
        });
        if (measure_types == "financial") {
            for (i = this.measures.length - 1; i >= 0; --i) {
                var m = this.measures[i];
                if ((m.irrelevant_additional_code == true) || (m.financial == false) || (m.relevant == false)) {
                    this.measures.splice(i, 1);
                }
            }
        } else {
            for (i = this.measures.length - 1; i >= 0; --i) {
                var m = this.measures[i];
                if ((m.irrelevant_additional_code == true) || (m.has_conditions == false) || (m.relevant == false)) {
                    this.measures.splice(i, 1);
                }
            }
        }
    }
remove_irrelevant_measures ( measure_types ) { var i ; this . measures . forEach ( m => { m . irrelevant_additional_code = false ; this . measure_types . forEach ( mt => { if ( mt . id == m . measure_type_id ) { m . financial = mt . financial ; m . measure_type_series_id = mt . measure_type_series_id ; } } ) ; var barred_codes = [ '2551' , '2552' ] ; var additional_code_id ; if ( m . additional_code != null ) { additional_code_id = m . additional_code . code } else { additional_code_id = "" ; } if ( barred_codes . includes ( additional_code_id ) ) { m . irrelevant_additional_code = true ; console . log ( "Splicing " + additional_code_id ) ; } if ( ( m . geographical_area_id == this . origin ) || ( m . geographical_area . member_strings . includes ( this . origin ) ) ) { m . relevant = true ; } } ) ; if ( measure_types == "financial" ) { for ( i = this . measures . length - 1 ; i >= 0 ; -- i ) { var m = this . measures [ i ] ; if ( ( m . irrelevant_additional_code == true ) || ( m . financial == false ) || ( m . relevant == false ) ) { this . measures . splice ( i , 1 ) ; } } } else { for ( i = this . measures . length - 1 ; i >= 0 ; -- i ) { var m = this . measures [ i ] ; if ( ( m . irrelevant_additional_code == true ) || ( m . has_conditions == false ) || ( m . relevant == false ) ) { this . measures . splice ( i , 1 ) ; } } } }
Remove any measures that are not financial or are not relevant to my country
Remove any measures that are not financial or are not relevant to my country
// Check that we are just looking at financial measures // Check that we are ignoring measures with a additional code of 2551 or 2552 // Check that we are just looking at measures aligned to the chosen country