* Optimize code.

This commit is contained in:
wangyuting
2022-11-25 00:38:38 +00:00
parent c9615e8ad9
commit 40ef984250
3 changed files with 12 additions and 4 deletions
+8 -1
View File
@@ -542,7 +542,14 @@ class build extends control
public function ajaxGetLastBuild($projectID, $executionID)
{
$lastBuild = $this->build->getLast($executionID, $projectID);
echo "<div class='help-block'> &nbsp; " . $this->lang->build->last . ": <a class='code label label-badge label-light' id='lastBuildBtn'>" . $lastBuild->name . "</a></div>";
if($lastBuild)
{
echo "<div class='help-block'> &nbsp; " . $this->lang->build->last . ": <a class='code label label-badge label-light' id='lastBuildBtn'>" . $lastBuild->name . "</a></div>";
}
else
{
echo '';
}
}
/**
+3 -2
View File
@@ -9,7 +9,7 @@ $().ready(function()
{
var productID = $('#product').val();
var branch = $('#branch').length > 0 ? $('#branch').val() : '';
$.get(createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=' + branch + '&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
$.get(createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + window.projectID + '&productID=' + productID + '&varName=builds&build=&branch=' + branch + '&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
{
if(data) $('#buildBox').html(data);
$('#builds').attr('data-placeholder', multipleSelect).chosen();
@@ -78,10 +78,11 @@ function loadProducts(executionID)
function loadLastBuild()
{
var isIntegrated = $('input[name=isIntegrated]:checked').val();
var projectID = $('#project').val();
var executionID = $('#execution').val();
if(isIntegrated == 'yes') executionID = 0;
$.get(createLink('build', 'ajaxGetLastBuild', 'projectID=' + projectID + '&executionID=' + executionID), function(data)
{
if(data) $('#lastBuildBox').html(data);
$('#lastBuildBox').html(data);
});
}
+1 -1
View File
@@ -321,7 +321,7 @@ class buildModel extends model
{
return $this->dao->select('id, name')->from(TABLE_BUILD)
->where('deleted')->eq(0)
->beginIF($executionID)->andWhere('execution')->eq((int)$executionID)->fi()
->andWhere('execution')->eq((int)$executionID)
->beginIF($projectID)->andWhere('project')->eq((int)$projectID)->fi()
->orderBy('date DESC,id DESC')
->limit(1)