Skip to content

Commit 120b49d

Browse files
committed
Add a separate job type to deploy just one post
1 parent 379f510 commit 120b49d

5 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/Controller.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ public static function wp2staticUISaveAdvancedOptions() : void {
472472
public static function wp2staticEnqueueJobs( ?int $post_id = null ) : void {
473473
// check each of these in order we want to enqueue
474474
$job_types = [
475+
'autoJobQueueDirectDeployPost' => 'direct_deploy_post',
475476
'autoJobQueueDetection' => 'detect',
476477
'autoJobQueueCrawling' => 'crawl',
477478
'autoJobQueuePostProcessing' => 'post_process',
@@ -630,7 +631,12 @@ public static function wp2staticProcessQueue() : void {
630631
break;
631632
case 'direct_deploy':
632633
$deployer = new DirectDeployer();
633-
634+
WsLog::l( 'Starting direct deployment' );
635+
$deployer->deploy();
636+
$deployer->deployComplete();
637+
break;
638+
case 'direct_deploy_post':
639+
$deployer = new DirectDeployer();
634640
$post_id = $job->triggering_post_id;
635641
if ( $post_id ) {
636642
$path = wp_make_link_relative(get_permalink($post_id));
@@ -639,12 +645,9 @@ public static function wp2staticProcessQueue() : void {
639645
WsLog::l( 'Starting direct deployment for path ' . $path );
640646
$deployer->deployPaths( $detected );
641647
} else {
642-
WsLog::l( 'Starting direct deployment' );
643-
$deployer->deploy();
648+
WsLog::w( 'No post ID found for direct deployment post' );
644649
}
645-
646650
$deployer->deployComplete();
647-
648651
break;
649652
default:
650653
WsLog::l( 'Trying to process unknown job type' );

src/CoreOptions.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ public static function optionSpecs() : array {
188188
'Direct Deploy',
189189
''
190190
),
191+
self::makeOptionSpec(
192+
'boolean',
193+
'autoJobQueueDirectDeployPost',
194+
'0',
195+
'Direct Deploy Post',
196+
''
197+
),
191198
self::makeOptionSpec(
192199
'string',
193200
'basicAuthUser',
@@ -824,6 +831,12 @@ public static function savePosted( string $screen = 'core' ) : void {
824831
[ 'name' => 'autoJobQueueDirectDeploy' ]
825832
);
826833

834+
$wpdb->update(
835+
$table_name,
836+
[ 'value' => isset( $_POST['autoJobQueueDirectDeployPost'] ) ? 1 : 0 ],
837+
[ 'name' => 'autoJobQueueDirectDeployPost' ]
838+
);
839+
827840
break;
828841
case 'advanced':
829842
$crawl_concurrency = intval( $_POST['crawlConcurrency'] );

src/JobQueue.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ public static function squashQueue() : void {
166166
'post_process',
167167
'deploy',
168168
'direct_deploy',
169+
'direct_deploy_post',
169170
];
170171

171172
foreach ( $job_types as $job_type ) {
172173
// get all jobs for a type where status is 'waiting'
173-
if ( $job_type === 'direct_deploy' ) {
174-
// Don't collapse direct_deploys that target a specific
174+
if ( $job_type === 'direct_deploy_post' ) {
175+
// Don't collapse direct_deploy_post jobs that target a specific
175176
// single post
176177
$waiting_jobs = $wpdb->get_results(
177178
"SELECT * FROM $table_name

src/ViewRenderer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ public static function renderJobsPage() : void {
263263
'autoJobQueuePostProcessing' => CoreOptions::get( 'autoJobQueuePostProcessing' ),
264264
'autoJobQueueDeployment' => CoreOptions::get( 'autoJobQueueDeployment' ),
265265
'autoJobQueueDirectDeploy' => CoreOptions::get( 'autoJobQueueDirectDeploy' ),
266+
'autoJobQueueDirectDeployPost' => CoreOptions::get( 'autoJobQueueDirectDeployPost' ),
266267
];
267268

268269
$view = apply_filters( 'wp2static_render_jobs_page_vars', $view );

views/jobs-page.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
<td style="text-align:center;">
104104
<?php echo $label( 'autoJobQueueDirectDeploy' ); ?>
105105
</td>
106+
<td style="text-align:center;">
107+
<?php echo $label( 'autoJobQueueDirectDeployPost' ); ?>
108+
</td>
106109
</tr>
107110
</thead>
108111
<tbody>
@@ -112,6 +115,7 @@
112115
<td><?php echo $input( 'autoJobQueuePostProcessing' ); ?></td>
113116
<td><?php echo $input( 'autoJobQueueDeployment' ); ?></td>
114117
<td><?php echo $input( 'autoJobQueueDirectDeploy' ); ?></td>
118+
<td><?php echo $input( 'autoJobQueueDirectDeployPost' ); ?></td>
115119
</tr>
116120
</tbody>
117121
</table>

0 commit comments

Comments
 (0)