PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.2.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.2.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
fluent-booking / vendor / woocommerce / action-scheduler / classes / migration / BatchFetcher.php

BatchFetcher.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 2.2.0, at vendor/woocommerce/action-scheduler/classes/migration/BatchFetcher.php

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