public static function launchCount($substatistic, $dynamicString)
 {
     if ($substatistic === 'Total') {
         if ($dynamicString === 'currentMonth') {
             return Cache::remember('stats:description:launchCount:total:currentMonth', 60, function () {
                 return Carbon::now()->format('F Y');
             });
         }
         if ($dynamicString === 'totalRockets') {
             return Cache::remember('stats:description:launchCount:total:totalRockets', 60, function () {
                 return Mission::whereComplete()->count();
             });
         }
     }
     if ($substatistic === 'Falcon 9') {
         if ($dynamicString === 'launchCount') {
             return Cache::remember('stats:description:launchCount:falcon9:launchCount', 60, function () {
                 return Mission::whereGenericVehicle('Falcon 9')->whereComplete()->count();
             });
         }
     }
     if ($substatistic === 'Falcon Heavy' || $substatistic === 'Falcon 1') {
         if ($dynamicString === 'launchCount') {
             return Cache::remember('stats:description:launchCount:' . $substatistic . ':launchCount', 60, function () use($substatistic) {
                 return Mission::whereSpecificVehicle($substatistic)->whereComplete()->count();
             });
         }
     }
 }
Exemplo n.º 2
0
 public function getLaunchProbabilityAttribute()
 {
     if ($this->status == MissionStatus::Upcoming) {
         $preciseEstimatedTimeOfLaunch = Carbon::instance(LaunchDateTimeResolver::parseString($this->launch_date_time)->getDateTime());
         $timeUntilLaunch = Carbon::now()->diffInSeconds($preciseEstimatedTimeOfLaunch);
         $delayedLaunches = count(DB::table('prelaunch_events')->select(['prelaunch_events.mission_id'])->where('event', 'Launch Change')->whereRaw('prelaunch_events.occurred_at > DATE_SUB(missions.launch_exact, INTERVAL ' . $timeUntilLaunch . ' SECOND)')->where('missions.status', 'Complete')->join('missions', 'missions.mission_id', '=', 'prelaunch_events.mission_id')->groupBy('missions.mission_id')->get());
         $totalLaunches = Mission::whereComplete()->count();
         return 1 / $totalLaunches * ($totalLaunches - $delayedLaunches);
     }
     return null;
 }
 /**
  * @param $substatistic
  * @return string
  */
 public static function kwajalein($substatistic)
 {
     if ($substatistic === 'Launches') {
         return Cache::remember('stats:kwajalein:launches', 60, function () {
             return Mission::whereComplete()->whereHas('launchSite', function ($q) {
                 $q->where('name', 'Omelek Island');
             })->count();
         });
     } else {
         if ($substatistic === 'Last Launch') {
             try {
                 $lastLaunch = Mission::lastFromLaunchSite('Omelek Island')->firstOrFail();
             } catch (ModelNotFoundException $e) {
                 return false;
             }
             return $lastLaunch;
         }
     }
 }