/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Fetch objects and delete redis sets
     $objects = Object::whereIn('object_id', Redis::smembers('objects:toReindex'))->get();
     $collections = Collection::whereIn('collection_id', Redis::smembers('collections:toReindex'))->get();
     $dataViews = DataView::whereIn('dataview_id', Redis::smembers('dataviews:toReindex'))->get();
     Redis::del(['objects:toReindex', 'collections:toReindex', 'dataviews:toReindex']);
     // Map to return searchable interfaces and reindex
     if ($objects->count() > 0) {
         foreach ($objects as $object) {
             $searchableObjects[] = $object->search();
         }
         Search::bulkReindex($searchableObjects);
     }
     if ($collections->count() > 0) {
         foreach ($collections as $collection) {
             $searchableCollections[] = $collection->search();
         }
         Search::bulkReindex($searchableCollections);
     }
     if ($dataViews->count() > 0) {
         foreach ($dataViews as $dataView) {
             $searchableDataViews[] = $dataView->search();
         }
         Search::bulkReindex($searchableDataViews);
     }
 }
Exemplo n.º 2
0
 /**
  * Function remove all redis data for specified language
  *
  * @param $language
  */
 public function clear($language)
 {
     if (Redis::del(Key::posts($language))) {
         $this->info('Remove all entries for key ' . Key::posts($language));
     }
     if (Redis::del(Key::tags($language))) {
         $this->info('Remove all entries for key ' . Key::tags($language));
     }
     foreach (Redis::keys(Key::post('*', $language)) as $key) {
         if (Redis::del($key)) {
             $this->info('Remove all entries for keys ' . $key);
         }
     }
 }
Exemplo n.º 3
0
 public static function deleteAdDetailsCache($job_id)
 {
     $sql = "SELECT a.id, a.dma_code\n\t\t\t   \t  FROM ad_jobs aj, ads a\n\t\t\t  \t WHERE aj.ad_id = a.id\n\t\t\t\t   AND aj.job_id = {$job_id}";
     $ads = DB::select($sql);
     foreach ($ads as $ad) {
         $cache_key = self::getAdDetailsCacheKey($ad->dma_code, $ad->id, $job_id);
         Redis::del($cache_key);
         $dma_cache_key = self::getDmaCacheKey($ad->dma_code);
         Redis::srem($dma_cache_key, $cache_key);
     }
 }
 /**
  * @return mixed
  */
 public function destroy()
 {
     // Disable access
     if (Auth::user()->isLaunchController()) {
         Auth::user()->launch_controller_flag = false;
         Auth::user()->save();
     }
     // Turn off SpaceXStats Live
     Redis::set('live:active', false);
     // Clean up all spacexstats live redis keys
     Redis::del(['live:streams', 'live:title', 'live:description', 'live:resources', 'live:sections', 'live:updates', 'live:countdown', 'live:discussion', 'live:isForLaunch', 'live:cannedResponses', 'live:reddit', 'live:status']);
     // Send out event
     event(new LiveEndedEvent());
     return response()->json(null, 204);
 }
Exemplo n.º 5
0
 public static function setFeaturedCompaniesCache($reset = false)
 {
     $cache_key = self::getFeaturedCompaniesCacheKey();
     if ($reset) {
         Redis::del($cache_key);
     }
     $exists = Redis::exists($cache_key);
     if (empty($exists)) {
         self::requestFeaturedCompaniesCache();
     }
 }
Exemplo n.º 6
0
 public function tidyUp()
 {
     $redisKey = config('rediskeys.digitalocean_token') . $this->provision->uuid;
     $sshKeys = new \App\Fodor\Ssh\Keys($this->provision->uuid);
     $adapter = new GuzzleHttpAdapter(Redis::get($redisKey));
     $digitalocean = new DigitalOceanV2($adapter);
     // ## REMOVE SSH KEYS FROM DIGITALOCEAN AND OUR LOCAL FILESYSTEM ##
     $keysFromDo = $digitalocean->key()->getAll();
     if (!empty($keysFromDo)) {
         foreach ($keysFromDo as $key) {
             if ($key->name == 'fodor-' . $this->provision->uuid) {
                 $digitalocean->key()->delete($key->id);
                 // Remove our fodor SSH key from the users DigitalOcean account
                 $this->log->addInfo("Removed SSH key: {$key->name}: {$key->id} from DigitalOcean");
             }
         }
     }
     if (\Storage::exists($sshKeys->getPublicKeyPath())) {
         try {
             $this->log->addInfo("Removed local SSH Keys");
             $sshKeys->remove();
             // uuid is the name of the file
         } catch (Exception $e) {
             // TODO: Handle.  We should probably be alerted as we don't want these lying around
         }
     }
     Redis::del($redisKey);
     $this->provision->dateready = (new \DateTime('now', new \DateTimeZone('UTC')))->format('c');
     $this->provision->exitcode = $this->exitCode;
     $this->provision->status = $this->exitCode === 0 ? 'ready' : 'errored';
     //TODO: Other distros or shells?
     $this->provision->save();
     //TODO: If it errored, an alert should be sent out for investigation
     $this->log->addInfo("Set provision row's status to {$this->provision->status}, we're done here");
 }
Exemplo n.º 7
0
 public static function setJobsByDmaCache($code, $reset = false)
 {
     $cache_key = self::getJobsByDmaCahceKey($code);
     if ($reset) {
         Redis::del($cache_key);
     }
     $exists = Redis::exists($cache_key);
     if (empty($exists)) {
         self::requestJobsByDmaCache($code);
     }
 }
Exemplo n.º 8
0
 public static function setDmaListCache($str, $reset = false)
 {
     $cache_key = self::getDmaListCacheKey($str);
     if ($reset) {
         Redis::del($cache_key);
     }
     $exists = Redis::exists($cache_key);
     if (empty($exists)) {
         self::requestDmaListCache($str);
     }
 }
Exemplo n.º 9
0
 public static function setKeywordJobsCache($keyword, $reset = false)
 {
     $cache_key = self::getKeywordJobsCacheKey($keyword);
     if ($reset) {
         Redis::del($cache_key);
     }
     $exists = Redis::exists($cache_key);
     if (empty($exists)) {
         self::requestKeywordJobsCache($keyword);
     }
 }
Exemplo n.º 10
0
 private static function requestCache()
 {
     $ads = self::where(['is_active' => 1])->select('copy', 'url_shorten as url')->orderBy('created_at', 'desc')->get()->toArray();
     $cache_key = self::getCacheKey();
     if (!empty($ads)) {
         Redis::set($cache_key, serialize($ads));
     } else {
         Redis::del($cache_key);
     }
 }