Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Jobs\backlogUpdate;

class Kernel extends ConsoleKernel
{
Expand All @@ -24,8 +25,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->job(new backlogUpdate)->dailyAt('13:00');
}

/**
Expand Down
54 changes: 54 additions & 0 deletions app/Jobs/backlogUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use App\Models\Item;
use GuzzleHttp\Client;

class backlogUpdate implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$webhook = env("WEBHOOK");
$published = DB::table('items')->where('status', '=', Item::PUBLISHED)->count();
$pending = DB::table('items')->where('status', '=', Item::PENDING)->count();
$changes = DB::table('items')->where('status', '=', Item::CHANGES_REQUESTED)->count();
$draft = DB::table('items')->where('status', '=', Item::DRAFT)->count();

$msg = <<<EOD
## *Current Entries*
**$draft** drafts
**$pending** pending review
**$changes** post-review, changes requested
**$published** published


EOD;

$client = new Client();
$res = $client->request('POST', $webhook, ["json" => ["content" => $msg]]);
}
}
Loading