age group sort added to dev
Miraculously seem to have figured out how to get the age_group to be used as a sorting field in the chart display, and to get the text value rather than the id value for the age ranges to show up in the Legend. Have it working in the dev instance. Will test further and then add it to the production instance tomorrow.
classes/Search/Single.php
1) modify
array('c.criminal_id', 'c.surname', 'c.given_name', 'c.age')
to
array('c.criminal_id', 'c.surname', 'c.given_name', 'c.age', 'c.age_group_id_fk')
classes/Search.php
1) modify
public $allowedGroups = array(
'age' => 'age',
'crime' => 'crime_group_text',
'gender' => 'gender_text',
'outcome' => 'outcome_group_text',
'respite' => 'respite_normalized_text'
);
to
public $allowedGroups = array(
'crime' => 'crime_group_text',
'gender' => 'gender_text',
'outcome' => 'outcome_group_text',
'respite' => 'respite_normalized_text',
'age_group' => 'age_group_text'
);
the first argument seems to have to be 'age_group', but I don't know why
the second argument has to match a field name in the selection generated by this object (e.g. if 'age_group_text' is replaced with 'age_group_id' then I get the ids rather than the text values)
2) added to function _prepareCriminals()
$this->_select->joinLeft(
array('ag' => 'age_groups'),
'ag.age_group_id = c.age_group_id_fk',
array('ag.age_group_text')
);
this adds the age_group_text to the generated results, allowing it to be referred to in the line of code that specifies the allowed_groups.