/** * @actionParam int item: Runresults ID. */ public function doAction() { $context = $this->getContext(); $db = $context->getDB(); $conf = $context->getConf(); $request = $context->getRequest(); $item = $request->getInt('item'); $row = $db->getRow(str_queryf('SELECT id, run_id, client_id, status, updated, created, result_url, build_url FROM runresults WHERE id = %u;', $item)); if (!$row) { $this->setError('invalid-input', 'Runresults ID not found.'); return; } $data = array(); $data['result_url'] = $row->result_url; $data['build_url'] = $row->build_url; // A job can be deleted without nuking the runresults, // this is by design so results stay permanently accessible // under a simple url. // If the job is no longer in existance, properties // 'otherRuns' and 'job' will be set to null. $runRow = $db->getRow(str_queryf('SELECT id, url, name, job_id FROM runs WHERE id = %u;', $row->run_id)); if (!$runRow) { $data['otherRuns'] = null; $data['job'] = null; } else { $data['otherRuns'] = JobAction::getDataFromRunRows($context, array($runRow)); $jobID = intval($runRow->job_id); $data['job'] = array('id' => $jobID, 'url' => swarmpath("job/{$jobID}", "fullurl")); } $clientRow = $db->getRow(str_queryf('SELECT id, name, useragent_id, useragent FROM clients WHERE id = %u;', $row->client_id)); $data['info'] = array('id' => intval($row->id), 'runID' => intval($row->run_id), 'clientID' => intval($row->client_id), 'status' => self::getStatus($row->status)); $data['client'] = array('id' => $clientRow->id, 'name' => $clientRow->name, 'uaID' => $clientRow->useragent_id, 'uaRaw' => $clientRow->useragent, 'viewUrl' => swarmpath('client/' . $clientRow->id)); // If still busy or if the client was lost, then the last update time is irrelevant // Alternatively this could test if $row->updated == $row->created, which would effectively // do the same. if ($row->status == self::$STATE_BUSY || $row->status == self::$STATE_LOST) { $data['info']['runTime'] = null; } else { $data['info']['runTime'] = gmstrtotime($row->updated) - gmstrtotime($row->created); self::addTimestampsTo($data['info'], $row->updated, 'saved'); } self::addTimestampsTo($data['info'], $row->created, 'started'); $this->setData($data); }
/** * @actionParam int item: Runresults ID. */ public function doAction() { $context = $this->getContext(); $db = $context->getDB(); $conf = $context->getConf(); $request = $context->getRequest(); $resultsID = $request->getInt('item'); $row = $db->getRow(str_queryf('SELECT run_id, client_id, status, error, total, fail, updated, created, report_html_size, LENGTH( report_html ) as \'compressed_size\' FROM runresults WHERE id = %u;', $resultsID)); if (!$row) { $this->setError('invalid-input', 'Runresults ID not found.'); return; } $data = array(); // A job can be deleted without nuking the runresults, // this is by design so results stay permanently accessible // under a simple url. // If the job is no longer in existance, properties // 'otherRuns' and 'job' will be set to null. $runRows = $db->getRows(str_queryf('SELECT id, url, name, job_id FROM runs WHERE id = %u;', $row->run_id)); if (!$runRows || !count($runRows)) { $data['otherRuns'] = null; $data['job'] = null; } else { $data['otherRuns'] = JobAction::getDataFromRunRows($db, $runRows); $jobID = intval($runRows[0]->job_id); $data['job'] = array('id' => $jobID, 'url' => swarmpath("job/{$jobID}", "fullurl")); } $clientRow = $db->getRow(str_queryf('SELECT id, user_id, useragent_id, useragent, device_name FROM clients WHERE id = %u;', $row->client_id)); $userRow = $db->getRow(str_queryf('SELECT id, name FROM users WHERE id = %u;', $clientRow->user_id)); $data['client'] = array('id' => $clientRow->id, 'uaID' => $clientRow->useragent_id, 'userAgent' => $clientRow->useragent, 'deviceName' => $clientRow->device_name, 'userID' => $userRow->id, 'userName' => $userRow->name, 'userUrl' => swarmpath('user/' . $userRow->name)); $data['resultInfo'] = array('id' => $resultsID, 'runID' => $row->run_id, 'fail' => $row->fail, 'total' => $row->total, 'error' => $row->error, 'clientID' => $row->client_id, 'status' => self::getStatus($row->status), 'reportHtmlSize' => $row->report_html_size, 'reportHtmlCompressedSize' => $row->compressed_size, 'reportHtmlCompressionRatio' => $row->report_html_size == 0 ? 0 : round(($row->report_html_size - $row->compressed_size) / $row->report_html_size * 100 / 1, 2)); // If still busy or if the client was lost, then the last update time is irrelevant // Alternatively this could test if $row->updated == $row->created, which would effectively // do the same. if ($row->status == self::$STATE_BUSY || $row->status == self::$STATE_LOST) { $data['resultInfo']['runTime'] = null; } else { $data['resultInfo']['runTime'] = gmstrtotime($row->updated) - gmstrtotime($row->created); self::addTimestampsTo($data['resultInfo'], $row->updated, 'saved'); } self::addTimestampsTo($data['resultInfo'], $row->created, 'started'); $this->setData($data); }