Adamw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/55449
Change subject: Reconstruct campaigns from the log
......................................................................
Reconstruct campaigns from the log
Change-Id: I4c0e275c211dde7fe661ed4077a5bc8100e51548
---
M includes/Campaign.php
M special/SpecialGlobalAllocation.php
2 files changed, 54 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/49/55449/1
diff --git a/includes/Campaign.php b/includes/Campaign.php
index 22486f6..bcaa744 100644
--- a/includes/Campaign.php
+++ b/includes/Campaign.php
@@ -188,6 +188,57 @@
}
/**
+ * Get all campaign configurations as of timestamp $ts
+ */
+ static function getHistoricalCampaigns( $ts ) {
+ global $wgCentralDBname;
+ $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
+ $res = $dbr->select(
+ "cn_notice_log",
+ array(
+ "log_id" => "MAX(notlog_id)",
+ ),
+ array(
+ "notlog_timestamp <= $ts",
+ "notlog_end_start <= $ts",
+ "notlog_end_end >= $ts",
+ "notlog_end_enabled = 1",
+ ),
+ __METHOD__,
+ array(
+ "GROUP BY" => "notlog_not_id",
+ )
+ );
+
+ $campaigns = array();
+ foreach ( $res as $row ) {
+ $singleRes = $dbr->select(
+ "cn_notice_log",
+ array(
+ "name" => "notlog_not_name",
+ "projects" => "notlog_end_projects",
+ "languages" => "notlog_end_languages",
+ "countries" => "notlog_end_countries",
+ "preferred" => "notlog_end_preferred",
+ "geo" => "notlog_end_geo",
+ "banners" => "notlog_end_banners",
+ "buckets" => "notlog_end_buckets",
+ ),
+ array(
+ "notlog_id = {$row->log_id}",
+ ),
+ __METHOD__
+ );
+
+ $row = $singleRes->fetchRow();
+ $row['banners'] = FormatJson::decode( $row['banners'],
true );
+
+ $campaigns[] = $row;
+ }
+ return $campaigns;
+ }
+
+ /**
* Get all the campaigns in the database
*
* @return array an array of campaign names
diff --git a/special/SpecialGlobalAllocation.php
b/special/SpecialGlobalAllocation.php
index 16349ac..c519b37 100644
--- a/special/SpecialGlobalAllocation.php
+++ b/special/SpecialGlobalAllocation.php
@@ -391,6 +391,9 @@
// This is annoying. Within the campaign, banners usually vary
by user
// logged-in status, and bucket. Determine the allocations and
// collapse any dimensions which do not vary.
+ //
+ // TODO: the allocation hash should also be used to collapse
groupings which
+ // are identical because of e.g. z-index
foreach ( array( true, false ) as $isAnon ) {
for ( $bucket = 0; $bucket < $numBuckets; $bucket++ ) {
$variations[$isAnon][$bucket] =
ApiCentralNoticeAllocations::getAllocationInformation(
--
To view, visit https://gerrit.wikimedia.org/r/55449
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c0e275c211dde7fe661ed4077a5bc8100e51548
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits