PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.4
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.4
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Libraries / action-scheduler / classes / migration / BatchFetcher.php

BatchFetcher.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.4, at app/Services/Libraries/action-scheduler/classes/migration/BatchFetcher.php

96 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Action_Scheduler\Migration;
4
5 use ActionScheduler_Store as Store;
6
7 /**
8 * Class BatchFetcher
9 *
10 * @package Action_Scheduler\Migration
11 *
12 * @since 3.0.0
13 *
14 * @codeCoverageIgnore
15 */
16 class BatchFetcher {
17 /**
18 * Store instance.
19 *
20 * @var ActionScheduler_Store
21 */
22 private $store;
23
24 /**
25 * BatchFetcher constructor.
26 *
27 * @param ActionScheduler_Store $source_store Source store object.
28 */
29 public function __construct( Store $source_store ) {
30 $this->store = $source_store;
31 }
32
33 /**
34 * Retrieve a list of actions.
35 *
36 * @param int $count The number of actions to retrieve.
37 *
38 * @return int[] A list of action IDs
39 */
40 public function fetch( $count = 10 ) {
41 foreach ( $this->get_query_strategies( $count ) as $query ) {
42 $action_ids = $this->store->query_actions( $query );
43 if ( ! empty( $action_ids ) ) {
44 return $action_ids;
45 }
46 }
47
48 return array();
49 }
50
51 /**
52 * Generate a list of prioritized of action search parameters.
53 *
54 * @param int $count Number of actions to find.
55 *
56 * @return array
57 */
58 private function get_query_strategies( $count ) {
59 $now = as_get_datetime_object();
60 $args = array(
61 'date' => $now,
62 'per_page' => $count,
63 'offset' => 0,
64 'orderby' => 'date',
65 'order' => 'ASC',
66 );
67
68 $priorities = array(
69 Store::STATUS_PENDING,
70 Store::STATUS_FAILED,
71 Store::STATUS_CANCELED,
72 Store::STATUS_COMPLETE,
73 Store::STATUS_RUNNING,
74 '', // any other unanticipated status.
75 );
76
77 foreach ( $priorities as $status ) {
78 yield wp_parse_args(
79 array(
80 'status' => $status,
81 'date_compare' => '<=',
82 ),
83 $args
84 );
85
86 yield wp_parse_args(
87 array(
88 'status' => $status,
89 'date_compare' => '>=',
90 ),
91 $args
92 );
93 }
94 }
95 }
96