Log.php 1.17 KiB
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Log extends Model
{
protected $table = 'logs';
protected $guarded = ['id'];
public static function getJobProgression(Wowa $wowa)
{
if ($wowa->status == Wowa::STATE_COLLECTION) {
$log = self::where('job_id', '=', $wowa->id)
->where('training', '=', false)->orderBy('progression', 'desc')->first();
if (!is_object($log)) {
return "Computation in progress...";
}
return $log->progression;
} elseif ($wowa->status == Wowa::STATE_RUNNING) {
$log = self::where('job_id', '=', $wowa->id)
->where('training', '=', true)->orderBy('progression', 'desc')->first();
if (!is_object($log)) {
return "Calculation progress...";
}
return ((($log->progression + 1) / $wowa->generation_number) * 100);
} elseif ($wowa->status == Wowa::STATE_SUCCESS) {
return "100";
} elseif ($wowa->status == Wowa::STATE_QUEUED) {
return "Computation in progress";
} else {
return 'Error';
}
}
}