コード例 #1
0
 public function update(SubscriptionService $subscriptionService, DeltaVCalculator $deltaV, $object_id)
 {
     if (Input::has(['status', 'visibility'])) {
         $object = Object::find($object_id);
         if (Input::get('status') == ObjectPublicationStatus::PublishedStatus) {
             DB::transaction(function () use($object, $subscriptionService, $deltaV) {
                 // Put the necessary files to S3 (and maybe local)
                 if (Input::get('visibility') == VisibilityStatus::PublicStatus) {
                     $object->putToLocal();
                 }
                 $job = (new PutObjectToCloudJob($object))->onQueue('uploads');
                 $this->dispatch($job);
                 // Update the object properties
                 $object->fill(Input::only(['status', 'visibility']));
                 $object->actioned_at = Carbon::now();
                 // Save the object if there's no errors
                 $object->save();
                 // Add the object to our elasticsearch node
                 Search::index($object->search());
                 // Create an award wih DeltaV
                 $award = Award::create(['user_id' => $object->user_id, 'object_id' => $object->object_id, 'type' => 'Created', 'value' => $deltaV->calculate($object)]);
                 // Once done, extend subscription
                 $subscriptionService->incrementSubscription($object->user, $award);
             });
         } elseif (Input::get('status') == "Deleted") {
             $object->delete();
         }
         return response()->json(null, 204);
     }
     return response()->json(false, 400);
 }
コード例 #2
0
 /**
  * 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);
     }
 }
コード例 #3
0
 public function get($object_id)
 {
     $object = Object::findOrFail($object_id);
     if ($object->isVisibleToUser() && $object->isInMissionControl()) {
         if (Auth::isSubscriber()) {
             JavaScript::put(['totalFavorites' => $object->favorites()->count(), 'isFavorited' => Auth::user()->favorites()->where('object_id', $object_id)->first(), 'userNote' => Auth::user()->notes()->where('object_id', $object_id)->first(), 'object' => $object]);
         }
         // Item has been viewed, increment!
         $object->incrementViewCounter();
         // Determine what type of object it is to show the correct view
         $viewType = strtolower(MissionControlType::getKey($object->type));
         return view('missionControl.objects.' . $viewType, ['object' => $object, 'moreLikeThis' => Search::moreLikeThis($object->search())]);
     }
     // Item cannot be viewed or does not exist
     return App::abort(401);
 }
コード例 #4
0
 public function search()
 {
     $results = Search::search(Input::get('search'));
     return response()->json($results);
 }