-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2153 from woocommerce/tweak/budget-recommendations
Tweak Budget recommendations logic
- Loading branch information
Showing
9 changed files
with
4,368 additions
and
4,289 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
declare( strict_types=1 ); | ||
|
||
namespace Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration; | ||
|
||
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Table\BudgetRecommendationTable; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Class Migration20231109T1653383133 | ||
* | ||
* Migration class to reload the default Ads budgets recommendations provided by Google on 9 Nov 2023 | ||
* | ||
* @package Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration | ||
* | ||
* @since x.x.x | ||
*/ | ||
class Migration20231109T1653383133 extends AbstractMigration { | ||
|
||
/** | ||
* @var BudgetRecommendationTable | ||
*/ | ||
protected $budget_rate_table; | ||
|
||
/** | ||
* Migration constructor. | ||
* | ||
* @param \wpdb $wpdb | ||
* @param BudgetRecommendationTable $budget_rate_table | ||
*/ | ||
public function __construct( \wpdb $wpdb, BudgetRecommendationTable $budget_rate_table ) { | ||
parent::__construct( $wpdb ); | ||
$this->budget_rate_table = $budget_rate_table; | ||
} | ||
|
||
|
||
/** | ||
* Returns the version to apply this migration for. | ||
* | ||
* @return string A version number. For example: 1.4.1 | ||
*/ | ||
public function get_applicable_version(): string { | ||
return 'x.x.x'; | ||
} | ||
|
||
/** | ||
* Apply the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function apply(): void { | ||
if ( $this->budget_rate_table->exists() && $this->budget_rate_table->has_column( 'daily_budget_low' ) ) { | ||
$this->wpdb->query( "ALTER TABLE `{$this->wpdb->_escape( $this->budget_rate_table->get_name() )}` DROP COLUMN `daily_budget_low`" ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
} | ||
|
||
if ( $this->budget_rate_table->exists() && $this->budget_rate_table->has_column( 'daily_budget_high' ) ) { | ||
$this->wpdb->query( "ALTER TABLE `{$this->wpdb->_escape( $this->budget_rate_table->get_name() )}` DROP COLUMN `daily_budget_high`" ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
|
||
} | ||
|
||
$this->budget_rate_table->reload_data(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters