Skip to content

Commit 0523623

Browse files
feat: add number of import jobs to survey data
1 parent 2682f58 commit 0523623

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

feedzy-rss-feed.php

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function run_feedzy_rss_feeds() {
130130
// to redirect all themeisle_log_event to error log.
131131
define( 'FEEDZY_LOCAL_DEBUG', false );
132132
define( 'FEEDZY_FEED_CUSTOM_TAG_NAMESPACE', 'http://feedzy.themeisle.com' );
133+
define( 'FEEDZY_IMPORT_JOBS_NUM_CACHE_KEY', 'feedzy_import_jobs_num' );
133134

134135
// always make this true before testing
135136
// also used in gutenberg.

includes/admin/feedzy-rss-feeds-admin.php

+23-2
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,26 @@ public function get_survey_data() {
20812081
$install_category = 91;
20822082
}
20832083

2084+
$import_jobs_num = get_transient( FEEDZY_IMPORT_JOBS_NUM_CACHE_KEY );
2085+
2086+
if ( false === $import_jobs_num ) {
2087+
$args = array(
2088+
'post_type' => 'feedzy_imports',
2089+
'posts_per_page' => 50,
2090+
'post_status' => array( 'publish', 'draft' ),
2091+
'fields' => 'ids',
2092+
'no_found_rows' => true,
2093+
'update_post_meta_cache' => false,
2094+
'update_post_term_cache' => false,
2095+
);
2096+
2097+
$query = new WP_Query( $args );
2098+
$import_jobs_num = count( $query->posts );
2099+
set_transient( FEEDZY_IMPORT_JOBS_NUM_CACHE_KEY, $import_jobs_num, 50 >= $import_jobs_num ? WEEK_IN_SECONDS : HOUR_IN_SECONDS );
2100+
} else {
2101+
$import_jobs_num = intval( $import_jobs_num );
2102+
}
2103+
20842104
$survey_data = array(
20852105
'environmentId' => 'clskgehf78eu5podwdrnzciti',
20862106
'attributes' => array(
@@ -2093,8 +2113,9 @@ public function get_survey_data() {
20932113
'plan' => $this->plan_category( $license_data ),
20942114
'days_since_install' => $install_category,
20952115
'install_days_number' => $days_since_install,
2096-
'license_status' => ! empty( $license_data->license ) ? $license_data->license : 'invalid'
2097-
),
2116+
'license_status' => ! empty( $license_data->license ) ? $license_data->license : 'invalid',
2117+
'import_jobs_num' => $import_jobs_num
2118+
),
20982119
);
20992120

21002121
if ( isset( $license_data->key ) ) {

0 commit comments

Comments
 (0)