jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/398778 )
Change subject: Reset deploy branch to match production
......................................................................
Reset deploy branch to match production
Will need to redo commits between 798e2467 and this one next week
Change-Id: I5d830389ff5f2fa7ca76d01467adfd248dc784dd
---
M civicrm
M composer.json
M composer.lock
M sites/all/modules/queue2civicrm/DonationQueueConsumer.php
D sites/all/modules/queue2civicrm/DonationStats.php
M sites/all/modules/queue2civicrm/queue2civicrm.info
M sites/all/modules/queue2civicrm/queue2civicrm.module
D sites/all/modules/queue2civicrm/tests/phpunit/DonationStatsTest.php
M sites/all/modules/thank_you/make_thank_you.drush.inc
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
M vendor
11 files changed, 44 insertions(+), 521 deletions(-)
Approvals:
jenkins-bot: Verified
Ejegg: Looks good to me, approved
diff --git a/civicrm b/civicrm
index b2fab9d..a82f2e7 160000
--- a/civicrm
+++ b/civicrm
@@ -1 +1 @@
-Subproject commit b2fab9d9d24b1187e845ec601f4165683278243c
+Subproject commit a82f2e7ea633af7477a2c8859b97dbe13ddda5d7
diff --git a/composer.json b/composer.json
index 81456c6..72a398e 100644
--- a/composer.json
+++ b/composer.json
@@ -25,8 +25,7 @@
"phpseclib/phpseclib": "~2.0",
"predis/predis": "1.*",
"twig/twig": "1.*",
- "wikimedia/composer-merge-plugin": "^1.4",
- "jackgleeson/stats-collector": "dev-master"
+ "wikimedia/composer-merge-plugin": "^1.4"
},
"repositories": [
{
diff --git a/composer.lock b/composer.lock
index 2ae68da..e06dee5 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at
https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "f5b1e547c9865d17802925641c804265",
+ "content-hash": "32a4c6d1dba52d233ae8892c1908badf",
"packages": [
{
"name": "addshore/psr-6-mediawiki-bagostuff-adapter",
@@ -353,65 +353,6 @@
"time": "2017-06-30T14:54:48+00:00"
},
{
- "name": "dflydev/dot-access-data",
- "version": "v1.1.0",
- "source": {
- "type": "git",
- "url":
"https://github.com/dflydev/dflydev-dot-access-data.git",
- "reference": "3fbd874921ab2c041e899d044585a2ab9795df8a"
- },
- "dist": {
- "type": "zip",
- "url":
"https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/3fbd874921ab2c041e899d044585a2ab9795df8a",
- "reference": "3fbd874921ab2c041e899d044585a2ab9795df8a",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Dflydev\\DotAccessData": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Dragonfly Development Inc.",
- "email": "[email protected]",
- "homepage": "http://dflydev.com"
- },
- {
- "name": "Beau Simensen",
- "email": "[email protected]",
- "homepage": "http://beausimensen.com"
- },
- {
- "name": "Carlos Frutos",
- "email": "[email protected]",
- "homepage": "https://github.com/cfrutos"
- }
- ],
- "description": "Given a deep data structure, access data by dot
notation.",
- "homepage": "https://github.com/dflydev/dflydev-dot-access-data",
- "keywords": [
- "access",
- "data",
- "dot",
- "notation"
- ],
- "time": "2017-01-20T21:14:22+00:00"
- },
- {
"name": "geoip2/geoip2",
"version": "v2.6.0",
"source": {
@@ -686,46 +627,6 @@
"password"
],
"time": "2014-11-20T16:49:30+00:00"
- },
- {
- "name": "jackgleeson/stats-collector",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/jackgleeson/stats-collector.git",
- "reference": "1c792bbeac77d4781fbb788f341b601636696df5"
- },
- "dist": {
- "type": "zip",
- "url":
"https://api.github.com/repos/jackgleeson/stats-collector/zipball/1c792bbeac77d4781fbb788f341b601636696df5",
- "reference": "1c792bbeac77d4781fbb788f341b601636696df5",
- "shasum": ""
- },
- "require": {
- "dflydev/dot-access-data": "^1.1"
- },
- "require-dev": {
- "phpunit/phpunit": "^6.4"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Statistics\\": "src/",
- "Samples\\": "samples/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jack Gleeson",
- "email": "[email protected]"
- }
- ],
- "description": "Utility to help record, analyse and export
statistics across any PHP process e.g. http request, batch jobs or cli-scrpts",
- "time": "2017-11-22T13:56:02+00:00"
},
{
"name": "league/csv",
@@ -2186,7 +2087,7 @@
"GPL-2.0"
],
"description": "Wikimedia Foundation payment processing library",
- "time": "2017-11-16T16:31:29+00:00"
+ "time": "2017-11-16 16:31:29"
},
{
"name": "wikimedia/omnimail-silverpop",
@@ -3884,7 +3785,6 @@
"stability-flags": {
"amzn/login-and-pay-with-amazon-sdk-php": 20,
"wikimedia/donation-interface": 20,
- "jackgleeson/stats-collector": 20,
"wikimedia/omnimail-silverpop": 20,
"mrmarkfrench/silverpop-php-connector": 20,
"omnimail/omnimail": 20
diff --git a/sites/all/modules/queue2civicrm/DonationQueueConsumer.php
b/sites/all/modules/queue2civicrm/DonationQueueConsumer.php
index 88a217c..3108d8c 100644
--- a/sites/all/modules/queue2civicrm/DonationQueueConsumer.php
+++ b/sites/all/modules/queue2civicrm/DonationQueueConsumer.php
@@ -1,11 +1,10 @@
<?php namespace queue2civicrm;
-use SmashPig\Core\DataStores\PendingDatabase;
use Queue2civicrmTrxnCounter;
+use SmashPig\Core\DataStores\PendingDatabase;
use SmashPig\Core\UtcDate;
use wmf_common\TransactionalWmfQueueConsumer;
use WmfException;
-use DonationStats;
class DonationQueueConsumer extends TransactionalWmfQueueConsumer {
@@ -69,21 +68,12 @@
_queue2civicrm_log( $log );
}
- $DonationStats = new DonationStats();
- $DonationStats->recordDonationStats( $message, $contribution );
+ $age = UtcDate::getUtcTimestamp() - UtcDate::getUtcTimestamp(
$contribution['receive_date'] );
-
- /**
- * === Legacy Donations Counter implementation ===
- */
- $age = UtcDate::getUtcTimestamp() - UtcDate::getUtcTimestamp(
$contribution['receive_date'] );
- $counter = Queue2civicrmTrxnCounter::instance();
- $counter->increment( $message['gateway'] );
- $counter->addAgeMeasurement( $message['gateway'], $age );
- /**
- * === End of Legacy Donations Counter implementation ===
- */
-
+ // keep count of the transactions
+ $counter = Queue2civicrmTrxnCounter::instance();
+ $counter->increment( $message['gateway'] );
+ $counter->addAgeMeasurement( $message['gateway'], $age );
// Delete any pending db entries with matching gateway and
order_id
PendingDatabase::get()->deleteMessage( $message );
diff --git a/sites/all/modules/queue2civicrm/DonationStats.php
b/sites/all/modules/queue2civicrm/DonationStats.php
deleted file mode 100644
index 1e930f4..0000000
--- a/sites/all/modules/queue2civicrm/DonationStats.php
+++ /dev/null
@@ -1,209 +0,0 @@
-<?php
-
-use Statistics\Collector\Collector;
-use Statistics\Exporter\Prometheus as PrometheusStatsExporter;
-use SmashPig\Core\UtcDate;
-
-/**
- * Class DonationStats
- *
- * Handles donation stats recording & exporting using Stats Collector
- *
- * @see Collector
- */
-class DonationStats {
-
- /**
- * Default output filename for Prometheus .prom file
- *
- * @var string
- */
- public $prometheusOutputFileName = "donations";
-
- /**
- * Custom Prometheus output file path. Default export behaviour is to use
drupal global
- * variable 'metrics_reporting_prometheus_path' unless this value is set.
- *
- * @var string
- */
- public $prometheusOutputFilePath;
-
- /**
- * @var Statistics\Collector\Collector
- */
- public $statsCollector;
-
- public function __construct() {
- $this->statsCollector = Collector::getInstance();
- // set the root namespace for all donation related stats
- $this->statsCollector->ns("donations");
- }
-
- /**
- * Record donation stats:
- * 1) Number of donations by gateway
- * 2) Number of overall donations
- * 3) Time between gateway transaction time and civiCRM import time (now)
- * 4) Gateway specific moving average of (3)
- * 5) Overall moving average of (3)
- * 6) Time between donation message enqueued time and civiCRM import time
(now)
- * 7) Gateway specific moving average of (6)
- * 8) Overall moving average of (6)
- *
- * @param array $message
- * @param array $contribution
- */
- public function recordDonationStats($message, $contribution) {
- $paymentGateway = $message['gateway'];
- $gatewayTransactionTime = $contribution['receive_date'];
-
- // donation counter
- $this->recordGatewayDonation($paymentGateway);
- $this->recordOverallDonations();
-
- // difference between gateway transaction time to civiCRM save time
- $this->recordGatewayTransactionAge($paymentGateway,
$gatewayTransactionTime);
- $this->recordAverageGatewayTransactionAge($paymentGateway);
- $this->recordOverallAverageGatewayTransactionAge();
-
- // difference between message enqueued time to civiCRM save time
- if (isset($message['source_enqueued_time'])) {
- $messageEnqueuedTime = $message['source_enqueued_time'];
- $this->recordMessageEnqueuedAge($paymentGateway, $messageEnqueuedTime);
- $this->recordAverageGatewayMessageEnqueuedAge($paymentGateway);
- $this->recordOverallAverageMessageEnqueuedAge();
- }
- }
-
- /**
- * Get overall average gateway transaction age at end of queue consumer
batch run
- *
- * @return float|int
- */
- public function getOverallAverageGatewayTransactionAge() {
- return $this->statsCollector->get("overall.average.transaction_age");
- }
-
- /**
- * Get overall average message age at end of queue consumer batch run
- *
- * @return float|int
- */
- public function getOverallAverageMessageEnqueuedAge() {
- return $this->statsCollector->get("overall.average.enqueued_age");
- }
-
- /**
- * Export recorded stats to an output format to then be consumed upstream.
- *
- * Currently we only export to Prometheus.
- */
- public function export() {
- $this->exportToPrometheus();
- }
-
- /**
- * Export stats data to a Prometheus .prom out file using the
- * PrometheusStatsExporter exporter.
- *
- * @see PrometheusStatsExporter
- */
- protected function exportToPrometheus() {
- // get the output file name and file path
- if (isset($this->prometheusOutputFilePath)) {
- $path = $this->prometheusOutputFilePath;
- } else {
- $path = variable_get(
- 'metrics_reporting_prometheus_path', '/var/spool/prometheus'
- );
- }
- $filename = $this->prometheusOutputFileName;
-
- // instantiate a Stats Collector Prometheus specific exporter and pass it
the current
- // instance of $statsCollector to then export all stats to
{$path}/{$filename}.prom
- $prometheusStatsExporter = new PrometheusStatsExporter($filename, $path);
- $prometheusStatsExporter->export($this->statsCollector);
- }
-
- /**
- * Record a stat to count/increment the number of gateway specific donations
- *
- * @param string $paymentGateway
- */
- protected function recordGatewayDonation($paymentGateway) {
- $this->statsCollector->inc("gateway.{$paymentGateway}", 1);
- }
-
- /**
- * Set/update the current total count of all donations during this queue
consumer run
- */
- protected function recordOverallDonations() {
- $this->statsCollector->clobber("overall.donations",
$this->statsCollector->sum("gateway.*"));
- }
-
- /**
- * Record a stat for the difference between gateway transaction time to
civiCRM save time
- *
- * @param string $paymentGateway
- * @param $gatewayTransactionTime
- */
- protected function recordGatewayTransactionAge($paymentGateway,
$gatewayTransactionTime) {
- // work out time between gateway's official transaction time and now
- $gatewayReceivedAge = UtcDate::getUtcTimestamp() -
UtcDate::getUtcTimestamp($gatewayTransactionTime);
- $this->statsCollector->add("transaction_age.{$paymentGateway}",
$gatewayReceivedAge);
- }
-
- /**
- * Set/update the current moving average of gateway transaction age
- *
- * @param string $paymentGateway
- */
- protected function recordAverageGatewayTransactionAge($paymentGateway) {
- $this->statsCollector->clobber("average.transaction_age.{$paymentGateway}",
- $this->statsCollector->avg("transaction_age.{$paymentGateway}")
- );
- }
-
- /**
- * Set/update the overall current moving average for all payment gateway
transaction ages
- */
- protected function recordOverallAverageGatewayTransactionAge() {
- $this->statsCollector->clobber("overall.average.transaction_age",
- $this->statsCollector->avg("transaction_age.*")
- );
- }
-
- /**
- * Record a stat for the difference between message enqueued time to civiCRM
save time
- *
- * @param string $paymentGateway
- * @param $messageEnqueuedTime
- */
- protected function recordMessageEnqueuedAge($paymentGateway,
$messageEnqueuedTime) {
- // work out time between the message enqueued time and now if
'source_enqueued_time' is set
- $enqueuedAge = UtcDate::getUtcTimestamp() - $messageEnqueuedTime;
- $this->statsCollector->add("enqueued_age.{$paymentGateway}", $enqueuedAge);
- }
-
- /**
- * Set/update the current moving average of gateway enqueued message ages
- *
- * @param string $paymentGateway
- */
- protected function recordAverageGatewayMessageEnqueuedAge($paymentGateway) {
- $this->statsCollector->clobber("average.enqueued_age.{$paymentGateway}",
- $this->statsCollector->avg("enqueued_age.{$paymentGateway}")
- );
- }
-
- /**
- * Set/update the current moving average of enqueued message ages
- */
- protected function recordOverallAverageMessageEnqueuedAge() {
- $this->statsCollector->clobber("overall.average.enqueued_age",
- $this->statsCollector->avg("enqueued_age.*")
- );
- }
-
-
-}
\ No newline at end of file
diff --git a/sites/all/modules/queue2civicrm/queue2civicrm.info
b/sites/all/modules/queue2civicrm/queue2civicrm.info
index a6cdd6d..40db4d2 100644
--- a/sites/all/modules/queue2civicrm/queue2civicrm.info
+++ b/sites/all/modules/queue2civicrm/queue2civicrm.info
@@ -6,6 +6,5 @@
dependencies[] = wmf_civicrm
package = queue2civicrm
files[] = Queue2civicrmTrxnCounter.php
-files[] = DonationStats.php
files[] = DonationQueueConsumer.php
diff --git a/sites/all/modules/queue2civicrm/queue2civicrm.module
b/sites/all/modules/queue2civicrm/queue2civicrm.module
index 1a7e300..3f2f4cc 100644
--- a/sites/all/modules/queue2civicrm/queue2civicrm.module
+++ b/sites/all/modules/queue2civicrm/queue2civicrm.module
@@ -9,7 +9,7 @@
*/
function queue2civicrm_menu() {
$items = array();
-
+
$items['admin/config/queue2civicrm'] = array(
'title' => 'Queue to CiviCRM',
'access arguments' => array('administer queue2civicrm'),
@@ -102,7 +102,7 @@
'#required' => TRUE,
'#default_value' => variable_get('queue2civicrm_batch_time', 90),
);
-
+
return system_settings_form($form);
}
@@ -135,13 +135,9 @@
);
$processed = $consumer->dequeueMessages();
- $DonationStats = new DonationStats();
- $DonationStats->export();
-
-
/**
- * === Legacy Donations Counter implementation ===
- *
+ * this may some day supersede the process counts handled above...
+ *
* Note that this might be a little whack. At least, it feels a little
sloppy.
* We might consider specifying the names of gateways to keep track of,
rather than auto-generate
* the gateways to keep track of during queue consumption. With the latter
(current) method,
@@ -163,17 +159,11 @@
}
module_invoke( 'metrics_reporting', 'report_metrics',
'donation_message_age', $ageMetrics );
- /**
- * === End of Legacy Donations Counter implementation ===
- */
-
if ($processed > 0) {
watchdog('queue2civicrm', 'Successfully processed ' . $processed . '
contribution(s).');
- watchdog('queue2civicrm',
- 'Average Transaction age: ' .
$DonationStats->getOverallAverageGatewayTransactionAge() . ' seconds.');
- watchdog('queue2civicrm',
- 'Average Message Enqueued age: ' .
$DonationStats->getOverallAverageMessageEnqueuedAge() . ' seconds.');
- } else {
+ watchdog('queue2civicrm', 'Average message age: ' . $ageMetrics['overall']
. ' seconds.');
+ }
+ else {
watchdog('queue2civicrm', 'No contributions processed.');
}
}
diff --git
a/sites/all/modules/queue2civicrm/tests/phpunit/DonationStatsTest.php
b/sites/all/modules/queue2civicrm/tests/phpunit/DonationStatsTest.php
deleted file mode 100644
index c4a2f83..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/DonationStatsTest.php
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-
-/**
- * The tests for the testOverallAverage*() methods are admittedly a little
confusing due to the
- * DonationStats API not allowing access to individual stat values once
recorded.
- *
- * However! fear not because even though testing averages to confirm
individual records appears
- * counter-intuitive, we are only adding a single donation per test meaning
the averages will be
- * identical be the individual values used per test because `avg(1) == 1`
- *
- * @group Queue2Civicrm
- * @group DonationStats
- */
-class DonationStatsTest extends BaseWmfDrupalPhpUnitTestCase {
-
- protected $statsFilename;
-
- protected $statsFilePath;
-
- protected $statsFileExtension;
-
- public function setUp() {
- parent::setUp();
- $this->setupStatsCollector();
- }
-
- public function testOverallAverageGatewayTransactionAgeRecorded() {
- $message = [
- 'gateway' => "ACME_PAYMENTS",
- ];
- $contribution = [
- //simulate a transaction date 1 hour earlier from now()
- 'receive_date' => \SmashPig\Core\UtcDate::getUtcDatabaseString('-1
hour'),
- ];
-
- $DonationStats = new DonationStats();
- $DonationStats->recordDonationStats($message, $contribution);
- $OverallAverageGatewayTransactionAge =
$DonationStats->getOverallAverageGatewayTransactionAge();
-
- //compare recorded stats data with expected age in seconds (3600 seconds =
1 hour)
- $this->assertEquals(3600, $OverallAverageGatewayTransactionAge);
- }
-
- public function testOverallAverageMessageEnqueuedAgeRecordedWhenPresent() {
- $message = [
- 'gateway' => "ACME_PAYMENTS",
- // populating 'source_enqueued_time' with a timestamp one hour earlier
from now()
- 'source_enqueued_time' => \SmashPig\Core\UtcDate::getUtcTimestamp('-1
hour'),
- ];
- $contribution = [
- 'receive_date' => \SmashPig\Core\UtcDate::getUtcDatabaseString('-1
hour'),
- ];
-
- $DonationStats = new DonationStats();
- $DonationStats->recordDonationStats($message, $contribution);
- $OverallAverageMessageEnqueuedAge =
$DonationStats->getOverallAverageMessageEnqueuedAge();
-
- //compare written stats data with expected age in seconds (3600 seconds =
1 hour)
- $this->assertEquals(3600, $OverallAverageMessageEnqueuedAge);
- }
-
- public function
testOverallAverageMessageEnqueuedAgeNotRecordedWhenNotPresent() {
- $message = [
- 'gateway' => "ACME_PAYMENTS",
- // omitting 'source_enqueued_time'
- ];
- $contribution = [
- 'receive_date' => \SmashPig\Core\UtcDate::getUtcDatabaseString(),
- ];
-
- $DonationStats = new DonationStats();
- $DonationStats->recordDonationStats($message, $contribution);
- $OverallAverageMessageEnqueuedAge =
$DonationStats->getOverallAverageMessageEnqueuedAge();
-
- $this->assertNull($OverallAverageMessageEnqueuedAge);
- }
-
- public function testExportingStatsToFile() {
- $this->setUpStatsOutFileProperties();
- $message = [
- 'gateway' => "ACME_PAYMENTS",
- ];
- $contribution = [
- 'receive_date' => \SmashPig\Core\UtcDate::getUtcDatabaseString(),
- ];
-
- // test output file does not currently exist
- $this->assertFileNotExists($this->statsFilePath . $this->statsFilename .
$this->statsFileExtension);
-
- $DonationStats = new DonationStats();
- $DonationStats->recordDonationStats($message, $contribution);
- $DonationStats->prometheusOutputFileName = $this->statsFilename;
- $DonationStats->prometheusOutputFilePath = rtrim($this->statsFilePath,
'/');
- $DonationStats->export();
-
- //test output file has been created
- $this->assertFileExists($this->statsFilePath . $this->statsFilename .
$this->statsFileExtension);
-
- // clean up
- $this->removeStatsOutFile();
- }
-
- public function testExportedStatsValues() {
- $this->setUpStatsOutFileProperties();
- $message = [
- 'gateway' => "ACME_PAYMENTS",
- ];
- $contribution = [
- //simulate a transaction date 1 hour earlier from now()
- 'receive_date' => \SmashPig\Core\UtcDate::getUtcDatabaseString('-1
hour'),
- ];
-
- $DonationStats = new DonationStats();
- $DonationStats->recordDonationStats($message, $contribution);
- $DonationStats->prometheusOutputFileName = $this->statsFilename;
- $DonationStats->prometheusOutputFilePath = rtrim($this->statsFilePath,
'/');
- $DonationStats->export();
-
- $expectedStats = [
- 'donations_gateway_ACME_PAYMENTS' => 1,
- 'donations_overall_donations' => 1,
- 'donations_overall_average_transaction_age' => 3600, // should be -1
hour from now (3600 secs)
- 'donations_average_transaction_age_ACME_PAYMENTS' => 3600,
- 'donations_transaction_age_ACME_PAYMENTS' => 3600,
- ];
-
- $statsFileFullPath = $this->statsFilePath . $this->statsFilename .
$this->statsFileExtension;
- $statsWrittenAssocArray = [];
- $statsWritten = rtrim(file_get_contents($statsFileFullPath)); // remove
trailing \n
- $statsWrittenLinesArray = explode("\n", $statsWritten);
- foreach ($statsWrittenLinesArray as $statsLine) {
- list($name, $value) = explode(' ', $statsLine);
- $statsWrittenAssocArray[$name] = $value;
- }
-
- //compare written stats data with expected
- $this->assertEquals($expectedStats, $statsWrittenAssocArray);
-
- // clean up
- $this->removeStatsOutFile();
- }
-
- public function tearDown() {
- parent::tearDown();
- }
-
- private function setUpStatsOutFileProperties() {
- $this->statsFilename = "test_stats";
- $this->statsFilePath = CRM_Utils_File::tempdir();
- $this->statsFileExtension = '.prom';
- }
-
- private function removeStatsOutFile() {
- unlink($this->statsFilePath . $this->statsFilename .
$this->statsFileExtension);
- rmdir($this->statsFilePath);
- }
-
- /**
- * Stats Collector singleton (used internally by DonationStats) needs
resetting before each test.
- *
- * DonationQueueTest indirectly records stats when calling
- * DonationQueueConsumer::processMessage() so we clear all instances before
each run to test
- * from a known starting point.
- *
- * @see DonationQueueTest
- */
- private function setupStatsCollector() {
- \Statistics\Collector\Collector::tearDown(TRUE);
- }
-
-
-}
diff --git a/sites/all/modules/thank_you/make_thank_you.drush.inc
b/sites/all/modules/thank_you/make_thank_you.drush.inc
index b7e98cf..b542966 100644
--- a/sites/all/modules/thank_you/make_thank_you.drush.inc
+++ b/sites/all/modules/thank_you/make_thank_you.drush.inc
@@ -17,6 +17,7 @@
function drush_make_thank_you() {
$generators = get_thank_you_generators();
+ $default_gen = get_default_thank_you_generator();
if (drush_get_option('listgen', false)) {
drush_print(t('Available thank you generators'));
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 9485811..184cedc 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -2501,6 +2501,9 @@
}
if (substr($moveField, 0, 13) === 'move_location') {
+ if (!isset($refs['is_major_gift'])) {
+ $refs['is_major_gift'] =
_wmf_civicrm_is_merged_contact_major_donor($mainId, $otherId);
+ }
$fieldParts = explode('_', $moveField);
if ($fieldParts[2] == 'email') {
@@ -2976,6 +2979,28 @@
}
/**
+ * Has the combined contact given $500 or more?
+ *
+ * @param int $mainId
+ * @param int $otherId
+ *
+ * @return bool
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+function _wmf_civicrm_is_merged_contact_major_donor($mainId, $otherId) {
+ $total = 0;
+ $donations = civicrm_api3('Contribution', 'get', array(
+ 'return' => 'total_amount',
+ 'contact_id' => array('IN' => array($mainId, $otherId)),
+ ));
+ foreach ($donations['values'] as $donation) {
+ $total += $donation['total_amount'];
+ }
+ return ($total >= 500) ? TRUE : FALSE;
+}
+
+/**
*
* We are testing a nuanced real life situation where the address data of the
* most recent donor gets priority - resulting in the primary address being set
diff --git a/vendor b/vendor
index e0bee4e..4a2f871 160000
--- a/vendor
+++ b/vendor
@@ -1 +1 @@
-Subproject commit e0bee4e764568f286bf14f2da1c14cfd8249e9d3
+Subproject commit 4a2f871ce564adfa60c15eabb53ad7fc2f85dcd3
--
To view, visit https://gerrit.wikimedia.org/r/398778
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5d830389ff5f2fa7ca76d01467adfd248dc784dd
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits