diff --git a/app/Console/Commands/RetrieveGitHubData.php b/app/Console/Commands/RetrieveGitHubData.php new file mode 100644 index 0000000..1c5dc89 --- /dev/null +++ b/app/Console/Commands/RetrieveGitHubData.php @@ -0,0 +1,46 @@ +failed()) { + Log::error($repositoryResponse->body()); + + return 1; + } + + if ($releasesResponse->failed()) { + Log::error($releasesResponse->body()); + + return 1; + } + + $data = json_decode($repositoryResponse->body(), null, 512, JSON_THROW_ON_ERROR); + $releases = json_decode($releasesResponse->body(), null, 512, JSON_THROW_ON_ERROR); + + Cache::put('stargazers', $data->stargazers_count); + Cache::put('downloads', $total = collect($releases) + ->where('prerelease', false) + ->sum(fn ($release) => collect($release->assets) + ->sum('download_count'))); + + $this->info("PHP Monitor currently has {$data->stargazers_count} stargazers and {$total} total downloads."); + + return 0; + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a45fa14..a88bd53 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -7,26 +7,13 @@ class Kernel extends ConsoleKernel { - /** - * Define the application's command schedule. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule - * @return void - */ protected function schedule(Schedule $schedule) { - // $schedule->command('inspire')->hourly(); + $schedule->command('github:fetch')->everySixHours(); } - /** - * Register the commands for the application. - * - * @return void - */ protected function commands() { $this->load(__DIR__.'/Commands'); - - // require base_path('routes/console.php'); } } diff --git a/resources/views/homepage.blade.php b/resources/views/homepage.blade.php index b14598d..7491690 100644 --- a/resources/views/homepage.blade.php +++ b/resources/views/homepage.blade.php @@ -66,8 +66,30 @@
PHP Monitor helps you set up and develop Laravel and Symfony projects. It's also great for WordPress or Drupal sites. In fact, it's a great companion for all kinds of projects, no matter the framework or CMS.
-This app is made with ♥ by Nico Verbruggen. It is open source and entirely free to use. Further development of this app is supported by your donations. You are also encouraged to star the repository on GitHub.
+This app is made with ♥ by Nico Verbruggen. It is open source and entirely free to use. Further development of this app is supported by your donations. + You are also encouraged to join the star the repository on GitHub. +
+ + GitHub Stats +
++ + {{ round(Cache::get('stargazers'), -2) / 1000 }}k + stargazers +
++ + {{ round(Cache::get('downloads'), -3) / 1000 }}k + total downloads +
+