mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 15:05:44 +00:00
NEW: Fixing queuedjob status and hiding report button when report is running
This commit is contained in:
parent
e9fe1a4707
commit
9e5a41f6c7
@ -25,7 +25,14 @@ class CheckExternalLinksJob extends AbstractQueuedJob implements QueuedJob {
|
||||
*/
|
||||
public function process() {
|
||||
$task = new CheckExternalLinks();
|
||||
$task->run();
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live');
|
||||
// set the limit so each page is done individually
|
||||
$task->limit = 1;
|
||||
$this->totalSteps = $pages->count();
|
||||
foreach ($pages as $page) {
|
||||
$this->currentStep++;
|
||||
$task->run();
|
||||
}
|
||||
$this->isComplete = true;
|
||||
return;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
class CheckExternalLinks extends BuildTask {
|
||||
public static $pageToProcess;
|
||||
public $limit = 10;
|
||||
|
||||
protected $title = 'Checking broken External links in the SiteTree';
|
||||
|
||||
protected $description = 'A task that records external broken links in the SiteTree';
|
||||
@ -20,10 +21,10 @@ class CheckExternalLinks extends BuildTask {
|
||||
->filter(array(
|
||||
'TrackID' => $track->ID,
|
||||
'Processed' => 0
|
||||
))->limit(10)->column('PageID');
|
||||
))->limit($this->limit)->column('PageID');
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live')
|
||||
->filter('ID', $batch)
|
||||
->limit(10);
|
||||
->limit($this->limit);
|
||||
$this->updateJobInfo('Fetching pages to check');
|
||||
if ($track->CompletedPages == $track->TotalPages) {
|
||||
$track->Status = 'Completed';
|
||||
@ -50,7 +51,7 @@ class CheckExternalLinks extends BuildTask {
|
||||
$batch = BrokenExternalPageTrack::get()
|
||||
->filter(array(
|
||||
'TrackID' => $track->ID
|
||||
))->limit(10)->column('PageID');
|
||||
))->limit($this->limit)->column('PageID');
|
||||
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Live')
|
||||
->filter('ID', $batch);
|
||||
@ -159,8 +160,13 @@ class CheckExternalLinks extends BuildTask {
|
||||
$row->delete();
|
||||
}
|
||||
} else {
|
||||
$this->updateJobInfo("Running next batch {$track->CompletedPages}/{$track->TotalPages}");
|
||||
$this->run($request);
|
||||
// if running via the queued job module return to the queued job after each iteration
|
||||
if ($this->limit == 1) {
|
||||
return;
|
||||
} else {
|
||||
$this->updateJobInfo("Running next batch {$track->CompletedPages}/{$track->TotalPages}");
|
||||
$this->run($request);
|
||||
}
|
||||
}
|
||||
|
||||
// run this again if queued jobs exists and is a valid int
|
||||
|
@ -2,7 +2,6 @@
|
||||
$('#externalLinksReport').entwine({
|
||||
onclick: function() {
|
||||
$(this).start();
|
||||
$(this).poll();
|
||||
},
|
||||
onmatch: function() {
|
||||
$(this).poll();
|
||||
@ -12,11 +11,13 @@
|
||||
$('#ReportHolder').empty();
|
||||
$('#ReportHolder').text('Running report 0%');
|
||||
$('#ReportHolder').append('<span class="ss-ui-loading-icon"></span>');
|
||||
$('#externalLinksReport').hide();
|
||||
$.ajax({url: "admin/externallinks/start", async: true, timeout: 3000 });
|
||||
$(this).poll();
|
||||
},
|
||||
poll: function() {
|
||||
// poll the current job and update the front end status
|
||||
$('#externalLinksReport').hide();
|
||||
$.ajax({
|
||||
url: "admin/externallinks/getJobStatus",
|
||||
async: true,
|
||||
@ -30,6 +31,7 @@
|
||||
var jobStatus = obj.Status ? obj.Status : 'Running';
|
||||
if (jobStatus == 'Completed') {
|
||||
$('#ReportHolder').text('Report Finished ' + completed + '/' + total);
|
||||
$('#externalLinksReport').show();
|
||||
} else {
|
||||
setTimeout(function() { $('#externalLinksReport').poll(); }, 1000);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user