/** * Get how many records in a model have each possible customFieldData value selected. * If the customFieldData doesn't exist yet, then return 0. */ public function getCollectionCountData() { if ($this->customFieldDataId > 0) { return GroupedAttributeCountUtil::getCountData('MultipleValuesCustomField', 'values', 'data', $this->customFieldDataId); } return 0; }
public function testFilteringByAttributeInDifferentTable() { $this->makeJModel(3, 5); $this->makeJModel(3, 6); $this->makeJModel(4, 5); $this->makeJModel(4, 6); $this->makeJModel(5, 6); $this->makeJModel(5, 6); $data = GroupedAttributeCountUtil::getCountData('J', 'jMember', 'name', 6); $this->assertEquals(array(3 => 1, 4 => 1, 5 => 2), $data); }
/** * Get how many records in the Contact and Lead models have each ContactState selected. * During testing, it is possible a contact or lead exists with a contact state id that no longer exists. * In that case, it is ignored from the count. */ public function getCollectionCountData() { $contactStates = ContactsUtil::getContactStateDataKeyedById(); $stateNameCountData = array(); $idCountData = GroupedAttributeCountUtil::getCountData('Contact', 'state'); foreach ($idCountData as $id => $count) { if (isset($contactStates[$id])) { $stateNameCountData[$contactStates[$id]] = $count; } } return $stateNameCountData; }