Skip to content

Commit

Permalink
fix(usage-reports): error handling in active campaign reports
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Sep 3, 2024
1 parent 99718ad commit 36de778
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,15 @@ private static function get_default_campaign_data() {
* @param int $last_n_days Number of last days to get the data about.
*/
private function get_campaign_data( $last_n_days ) {
$last_campaigns_data = get_option( self::LAST_CAMPAIGNS_DATA_OPTION_NAME );
$campaigns_data = self::get_default_campaign_data();

$current_campaign_data = $this->get_current_campaign_data( $last_n_days );
if ( \is_wp_error( $current_campaign_data ) ) {
return $current_campaign_data;
}

update_option( self::LAST_CAMPAIGNS_DATA_OPTION_NAME, $current_campaign_data );
$campaigns_data = self::get_default_campaign_data();

$last_campaigns_data = get_option( self::LAST_CAMPAIGNS_DATA_OPTION_NAME );
if ( ! $last_campaigns_data ) {
// No data about campaigns yet, so there is nothing to compare the new data with.
return $campaigns_data;
Expand Down

0 comments on commit 36de778

Please sign in to comment.