Skip to content

Commit

Permalink
Do not erase logged commandline
Browse files Browse the repository at this point in the history
Notify when try run app without runtemplate id
  • Loading branch information
Vitexus committed May 10, 2024
1 parent 295894d commit e1545af
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
10 changes: 7 additions & 3 deletions src/MultiFlexi/Job.php
Expand Up @@ -164,7 +164,7 @@ public function newJob(int $companyId, int $appId, array $environment, string $s
*/
public function runBegin()
{
$appId = $this->application->getMyKey();
$appId = $this->application->getMyKey();
$companyId = $this->company->getMyKey();
$this->setObjectName();
$sqlLogger = LogToSQL::singleton();
Expand All @@ -173,7 +173,10 @@ public function runBegin()
if (is_null($this->runTemplate)) {
$this->runTemplate = new RunTemplate();
}
$this->runTemplate->loadFromSQL($this->runTemplate->runTemplateID($appId, $companyId));
if($this->runTemplate->getMyKey() == 0){
$this->runTemplate->loadFromSQL($this->runTemplate->runTemplateID($appId, $companyId));
$this->addStatusMessage(_('Job launched without runtemplate ID'), 'error');
}
$jobId = $this->getMyKey();
//$this->addStatusMessage('JOB: ' . $jobId . ' ' . json_encode($this->environment), 'debug');
if (\Ease\Shared::cfg('ZABBIX_SERVER')) {
Expand Down Expand Up @@ -214,7 +217,7 @@ public function runEnd($statusCode, $stdout, $stderr)
'end' => new \Envms\FluentPDO\Literal(\Ease\Shared::cfg('DB_CONNECTION') == 'sqlite' ? "date('now')" : 'NOW()'),
'stdout' => addslashes($stdout),
'stderr' => addslashes($stderr),
'command' => $this->commandline,
//'command' => $this->commandline,
'exitcode' => $statusCode
], ['id' => $this->getMyKey()]);
}
Expand Down Expand Up @@ -532,6 +535,7 @@ public function takeData($data)

if($this->application->getMyKey() && $this->company->getMyKey()){
$this->runTemplate->loadFromSQL($this->runTemplate->runTemplateID($this->application->getMyKey(), $this->company->getMyKey()));
$this->addStatusMessage(_('No runtemplate ID proveided'), 'warning');
}

if ($this->getDataValue('executor')) {
Expand Down
72 changes: 36 additions & 36 deletions src/apps.php
Expand Up @@ -22,42 +22,42 @@

$allAppData = $servers->getAll();

$jobsDataRaw = (new \MultiFlexi\Job())->listingQuery()->select(['app_id','exitcode'])->fetchAll();
foreach ($jobsDataRaw as $jobData) {
$exitcodeCounts = [];
$exitcodeSuccess = [];

foreach ($jobsData as $jobData) {
$app_id = $jobData['app_id'];
$exitcode = $jobData['exitcode'];

if (!isset($exitcodeCounts[$app_id])) {
$exitcodeCounts[$app_id] = [];
$exitcodeSuccess[$app_id] = [];
}

if (!isset($exitcodeCounts[$app_id][$exitcode])) {
$exitcodeCounts[$app_id][$exitcode] = 0;
$exitcodeSuccess[$app_id][$exitcode] = 0;
}

$exitcodeCounts[$app_id][$exitcode]++;
if ($exitcode == 0) {
$exitcodeSuccess[$app_id][$exitcode]++;
}
}

$averageSuccess = [];

foreach ($exitcodeCounts as $app_id => $exitcodes) {
$averageSuccess[$app_id] = [];

foreach ($exitcodes as $exitcode => $count) {
$averageSuccess[$app_id][$exitcode] = $exitcodeSuccess[$app_id][$exitcode] / $count;
}
}
$jobsData[$jobData['app_id']] = $jobData['exitcode'];
}
//$jobsDataRaw = (new \MultiFlexi\Job())->listingQuery()->select(['app_id','exitcode'])->fetchAll();
//foreach ($jobsDataRaw as $jobData) {
// $exitcodeCounts = [];
// $exitcodeSuccess = [];
//
// foreach ($jobsData as $jobData) {
// $app_id = $jobData['app_id'];
// $exitcode = $jobData['exitcode'];
//
// if (!isset($exitcodeCounts[$app_id])) {
// $exitcodeCounts[$app_id] = [];
// $exitcodeSuccess[$app_id] = [];
// }
//
// if (!isset($exitcodeCounts[$app_id][$exitcode])) {
// $exitcodeCounts[$app_id][$exitcode] = 0;
// $exitcodeSuccess[$app_id][$exitcode] = 0;
// }
//
// $exitcodeCounts[$app_id][$exitcode]++;
// if ($exitcode == 0) {
// $exitcodeSuccess[$app_id][$exitcode]++;
// }
// }
//
// $averageSuccess = [];
//
// foreach ($exitcodeCounts as $app_id => $exitcodes) {
// $averageSuccess[$app_id] = [];
//
// foreach ($exitcodes as $exitcode => $count) {
// $averageSuccess[$app_id][$exitcode] = $exitcodeSuccess[$app_id][$exitcode] / $count;
// }
// }
// $jobsData[$jobData['app_id']] = $jobData['exitcode'];
//}


$fbtable = new Table();
Expand Down

0 comments on commit e1545af

Please sign in to comment.