You are here

function google_analytics_counter_update_8011 in Google Analytics Counter 8.3

Issue #3031429: Dashboard not reporting correctly.

File

./google_analytics_counter.install, line 416
Update, and uninstall functions for the Google Analytics Counter module.

Code

function google_analytics_counter_update_8011() {
  $config_factory = \Drupal::configFactory();

  // Get the existing start date.
  $start_date = $config_factory
    ->getEditable('google_analytics_counter.settings')
    ->get('general_settings.start_date');
  switch ($start_date) {
    case '30 days ago':
      $config_factory
        ->getEditable('google_analytics_counter.settings')
        ->set('general_settings.start_date', '30 days ago')
        ->save();
      $config_factory
        ->getEditable('google_analytics_counter.settings')
        ->set('general_settings.end_date', '30 days ago +30 days -1 day')
        ->save();
      break;
    case '3 months ago':
      $config_factory
        ->getEditable('google_analytics_counter.settings')
        ->set('general_settings.start_date', '3 months ago')
        ->save();
      $config_factory
        ->getEditable('google_analytics_counter.settings')
        ->set('general_settings.end_date', '3 months ago +3 months -1 day')
        ->save();
      break;
    case '6 months ago':
      $config_factory
        ->getEditable('google_analytics_counter.settings')
        ->set('general_settings.start_date', '6 months ago')
        ->save();
      $config_factory
        ->getEditable('google_analytics_counter.settings')
        ->set('general_settings.end_date', '6 months ago +6 months - 1 day')
        ->save();
      break;
    default:
      break;
  }
}