PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / vendor / woocommerce / action-scheduler / classes / migration / BatchFetcher.php
hostinger-reach / vendor / woocommerce / action-scheduler / classes / migration Last commit date
ActionMigrator.php 9 months ago ActionScheduler_DBStoreMigrator.php 9 months ago BatchFetcher.php 9 months ago Config.php 9 months ago Controller.php 9 months ago DryRun_ActionMigrator.php 9 months ago DryRun_LogMigrator.php 9 months ago LogMigrator.php 9 months ago Runner.php 9 months ago Scheduler.php 9 months ago
BatchFetcher.php
96 lines
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