* [misc] adjust job sync logic for visit browse page.

This commit is contained in:
caoyanyi
2025-01-15 13:27:16 +08:00
committed by 李阳
parent 7c4375d047
commit f38aa4d823
4 changed files with 20 additions and 6 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ class compileTao extends compileModel
$updatedDate = isset($build->updated_at) ? strtotime($build->updated_at) : $createdDate;
if(isset($build->updated))
{
if(strlen($build->updated) > 10) $updatedDate = intval($build->updated / 1000);
if(strlen((string)$build->updated) > 10) $updatedDate = intval($build->updated / 1000);
$updatedDate = $build->updated;
}
$data->updateDate = date('Y-m-d H:i:s', $updatedDate);
+2 -2
View File
@@ -15,7 +15,7 @@ window.renderCell = function(result, {col, row})
window.importJob = function()
{
if(repoID === undefined || repoID === null || typeof repoID != "number" || !canImportJob) return;
if(repoID === undefined || repoID === null || typeof repoID != "number") return;
var url = $.createLink('job', 'ajaxImportJobs', "repoID=" + repoID);
$.getJSON(url, function(data)
@@ -34,4 +34,4 @@ window.importJob = function()
$(function()
{
importJob();
});
});
+17 -2
View File
@@ -573,17 +573,32 @@ class jobModel extends model
$job->server = $repo->serviceHost;
$job->createdBy = 'system';
$addedPipelines = array();
$jobs = $this->dao->select('id, pipeline')->from(TABLE_JOB)->where('repo')->eq($repoID)->fetchPairs();
$existsPipelines = array();
foreach($jobs as $pipeline)
{
if(empty($pipeline)) continue;
$pipeline = json_decode($pipeline);
if(empty($pipeline)) continue;
$existsPipelines[] = $pipeline->reference;
}
$addedPipelines = array();
foreach($pipelines as $pipeline)
{
if(!empty($pipeline->disabled)) continue;
$ref = isset($pipeline->ref) ? $pipeline->ref : $pipeline->default_branch;
if(in_array($ref, $existsPipelines)) continue;
$createdDate = helper::now();
if(isset($pipeline->created_at)) $createdDate = date('Y-m-d H:i:s', strtotime($pipeline->created_at));
$job->createdDate = $createdDate;
if(isset($pipeline->updated_at)) $job->editedDate = date('Y-m-d H:i:s', strtotime($pipeline->updated_at));
$pipelineMeta = array('project' => $repo->serviceProject, 'reference' => isset($pipeline->ref) ? $pipeline->ref : $pipeline->default_branch);
$pipelineMeta = array('project' => $repo->serviceProject, 'reference' => $ref);
$job->pipeline = json_encode($pipelineMeta);
$hash = md5($job->pipeline);
-1
View File
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace zin;
jsVar('repoID', $repoID);
jsVar('canImportJob', empty($jobList));
if($repoID)
{