Пример #1
0
 /**
  * @param $module WikiaHubsModuleService
  */
 private function purgeCache($module)
 {
     global $wgCityId, $wgDisableWAMOnHubs;
     $module->purgeMemcache($this->date);
     $this->getHubsServicesHelper()->purgeHubV3Varnish($wgCityId);
     if (!$wgDisableWAMOnHubs && $this->selectedModuleId == WikiaHubsModuleSliderService::MODULE_ID && $this->date == $this->editHubModel->getLastPublishedTimestamp($wgCityId, null)) {
         $this->purgeWikiaHomepageHubs();
     }
 }
Пример #2
0
 public function getRealDataV3($cityId, $prevTimestamp = null)
 {
     if ($cityId === 0) {
         return [];
     }
     $currentData = $this->getDataFromModulesV3($cityId);
     $timestamp = $this->editHubModel->getLastPublishedTimestamp($cityId, $prevTimestamp);
     foreach ($currentData as &$val) {
         $val['timestamp'] = $timestamp;
     }
     $prevTimestamp = $timestamp - 1;
     for ($i = 0; $i < self::MAX_DATE_LOOP; $i++) {
         $prevTimestamp = $this->editHubModel->getLastPublishedTimestamp($cityId, $prevTimestamp);
         $prevData = null;
         if ($prevTimestamp) {
             $prevData = $this->getDataFromModulesV3($cityId, $prevTimestamp);
         }
         if ($prevData === null) {
             $prevTimestamp--;
             continue;
         }
         foreach ($currentData as $url => &$val) {
             if (array_key_exists($url, $prevData)) {
                 $val['timestamp'] = $prevTimestamp;
             }
         }
         $prevTimestamp--;
     }
     $prevTimestamp++;
     foreach ($currentData as $url => &$val) {
         if ($val['timestamp'] === $prevTimestamp) {
             $val['timestamp'] = self::MIN_DATE_FOUND;
         }
     }
     $timestamps = [];
     // Obtain a list of columns
     foreach ($currentData as $key => $row) {
         $timestamps[$key] = $row['timestamp'];
     }
     array_multisort($timestamps, SORT_DESC, $currentData);
     return $currentData;
 }
 public function loadData(EditHubModel $model, $params)
 {
     $hubParams = $this->getHubsParams();
     $lastTimestamp = $model->getLastPublishedTimestamp($hubParams, $params['ts']);
     $structuredData = WikiaDataAccess::cache($this->getMemcacheKey($lastTimestamp, $this->skinName), 6 * 60 * 60, function () use($model, $params) {
         return $this->loadStructuredData($model, $params);
     });
     if ($this->getShouldFilterCommercialData()) {
         $structuredData = $this->filterCommercialData($structuredData);
     }
     return $structuredData;
 }