Skip to content

Commit

Permalink
dev/core1329 Reduce number of deceased contacts in the demo data from…
Browse files Browse the repository at this point in the history
… 31 to 12

Limit number of deceased contacts to 4 and add in age checks as per Justin
  • Loading branch information
seamuslee001 committed Nov 27, 2019
1 parent 00e7a58 commit ca7a715
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 36 deletions.
12 changes: 11 additions & 1 deletion sql/GenerateData.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public function initID() {

private $groupMembershipStatus = array('Added', 'Removed', 'Pending');
private $subscriptionHistoryMethod = array('Admin', 'Email');
private $deceasedContactIds = array();

/*********************************
* private methods
Expand Down Expand Up @@ -649,7 +650,13 @@ private function addIndividual() {
}

// Deceased probability based on age
if ($age > 40) {
if ($contact->gender_id && $contact->gender_id == 2) {
$checkAge = 64;
}
else {
$checkAge = 68;
}
if ($age > $checkAge && count($this->deceasedContactIds) < 4) {
$contact->is_deceased = $this->probability(($age - 30) / 100);
if ($contact->is_deceased && $this->probability(.7)) {
$contact->deceased_date = $this->randomDate();
Expand Down Expand Up @@ -686,6 +693,9 @@ private function addIndividual() {
$contact->hash = crc32($contact->sort_name);
$contact->id = $cid;
$this->_update($contact);
if ($contact->is_deceased) {
$this->deceasedContactIds[] = $cid;
}
}
}

Expand Down
68 changes: 33 additions & 35 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

0 comments on commit ca7a715

Please sign in to comment.