Merge branch 'trunk'
This commit is contained in:
commit
3628312002
4 changed files with 40 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ class StatusCheckerController extends Controller
|
|||
->firstOrNew();
|
||||
|
||||
$project_sc->fill($request->validated());
|
||||
$project_sc->last_call = \now();
|
||||
return $project_sc->save() ? response('OK') : response('KO');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,11 +128,11 @@ class Project extends Model
|
|||
*/
|
||||
public function getCheckedAttribute()
|
||||
{
|
||||
$value = ProjectStatusChecker::select('updated_at')->where('project_uuid', '=', $this->uuid)->first();
|
||||
$value = ProjectStatusChecker::select('last_call')->where('project_uuid', '=', $this->uuid)->first();
|
||||
if (!$value) {
|
||||
$value = 'missing';
|
||||
} else {
|
||||
$value = $value->updated_at;
|
||||
$value = $value->last_call;
|
||||
$dt = Carbon::now();
|
||||
if ($dt->diffInMinutes($value) > 30) {
|
||||
$value = 'false';
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ class ProjectStatusChecker extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'project_uuid', 'code', 'sitemap', 'robots', 'logs'
|
||||
'project_uuid', 'code', 'sitemap', 'robots', 'logs', 'last_call'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterStatuscheckerTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('project_status_checkers', function (Blueprint $table) {
|
||||
$table->unsignedSmallInteger('sitemap')->comment('Has sitemap ?')->change();
|
||||
$table->unsignedSmallInteger('robots')->comment('Has robots.txt ?')->change();
|
||||
$table->dateTime('last_call')->default('1970-01-01')->comment('Last API call date')->after('logs');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('project_status_checkers', function (Blueprint $table) {
|
||||
$table->string('sitemap', 20)->change();
|
||||
$table->string('robots', 20)->change();
|
||||
$table->dropColumn('last_call');
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue