PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
sitepress-multilingual-cms
/
classes
/
ATE
<?php namespace WPML\TM\ATE; use WPML\Element\API\Languages; use WPML\FP\Cast; use WPML\FP\Fns; use WPML\FP\Lst; use WPML\FP\Obj; use WPML\TM\ATE\Review\ReviewStatus; class Jobs { const LONGSTANDING_AT_ATE_SYNC_COUNT = 100; /** * @param array $statuses * * @return array */ public static function getJobsWithStatus( array $statuses ) { if ( ! $statuses ) { return []; } global $wpdb; $needsReviewCondition = '1=0'; if ( Lst::includes( ICL_TM_NEEDS_REVIEW, $statuses ) ) { $reviewStatuses = wpml_prepare_in( [ ReviewStatus::NEEDS_REVIEW, ReviewStatus::EDITING ] ); $needsReviewCondition = 'translation_status.review_status IN ( ' . $reviewStatuses . ' )'; } $statuses = \wpml_prepare_in( $statuses, '%d' ); $languages = \wpml_prepare_in( Lst::pluck( 'code', Languages::getActive() ) ); $sql = " SELECT jobs.rid, MAX(jobs.job_id) as jobId, jobs.editor_job_id as ateJobId, jobs.automatic , translation_status.status, translation_status.review_status, jobs.ate_sync_count > " . static::LONGSTANDING_AT_ATE_SYNC_COUNT . " as isLongstanding FROM {$wpdb->prefix}icl_translate_job as jobs INNER JOIN {$wpdb->prefix}icl_translation_status translation_status ON translation_status.rid = jobs.rid INNER JOIN {$wpdb->prefix}icl_translations translations ON translation_status.translation_id = translations.translation_id INNER JOIN {$wpdb->prefix}icl_translations parent_translations ON translations.trid = parent_translations.trid AND parent_translations.source_language_code IS NULL INNER JOIN {$wpdb->prefix}posts posts ON parent_translations.element_id = posts.ID WHERE jobs.editor = %s AND ( translation_status.status IN ({$statuses}) OR $needsReviewCondition ) AND translations.language_code IN ({$languages}) AND posts.post_status <> 'trash' GROUP BY jobs.rid; "; return Fns::map( Obj::evolve( [ 'rid' => Cast::toInt(), 'jobId' => Cast::toInt(), 'ateJobId' => Cast::toInt(), 'automatic' => Cast::toBool(), 'status' => Cast::toInt(), 'isLongstanding' => Cast::toBool(), ] ), $wpdb->get_results( $wpdb->prepare( $sql, \WPML_TM_Editors::ATE ) ) ); } /** * @return array */ public static function getJobsToSync() { return self::getJobsWithStatus( [ ICL_TM_WAITING_FOR_TRANSLATOR, ICL_TM_IN_PROGRESS, ICL_TM_ATE_NEEDS_RETRY ] ); } /** * @return array */ public static function getJobsToRetry() { return self::getJobsWithStatus( [ ICL_TM_ATE_NEEDS_RETRY ] ); } /** * @return int */ public static function getTotal() { global $wpdb; $sql = " SELECT COUNT(jobs.job_id) FROM {$wpdb->prefix}icl_translate_job as jobs WHERE jobs.editor = %s "; return (int) $wpdb->get_var( $wpdb->prepare( $sql, \WPML_TM_Editors::ATE ) ); } /** * @return bool */ public static function isThereJob() { global $wpdb; $noOfRowsToFetch = 1; $sql = $wpdb->prepare( "SELECT EXISTS(SELECT %d FROM {$wpdb->prefix}icl_translate_job)", $noOfRowsToFetch ); return boolval( $wpdb->get_var( $sql ) ); } }
[+]
Log
[-] class-wpml-tm-ate-status.php
[edit]
[+]
Hooks
[-] class-wpml-tm-ate-jobs.php
[edit]
[+]
models
[-] class-wpml-tm-ams-user-sync.php
[edit]
[+]
TranslateEverything
[+]
Retry
[+]
Download
[-] StatusBar.php
[edit]
[-] class-wpml-tm-ams-translator-activation-records.php
[edit]
[+]
auto-translate
[-] JobRecord.php
[edit]
[-] ReturnedJobsQueue.php
[edit]
[-] class-wpml-tm-ate-job.php
[edit]
[-] Loader.php
[edit]
[-] StatusIcons.php
[edit]
[+]
proxies
[+]
Sync
[+]
sitekey
[-] class-wpml-tm-ams-users.php
[edit]
[+]
..
[+]
REST
[-] class-wpml-tm-ate-ams-endpoints.php
[edit]
[-] class-wpml-tm-ate.php
[edit]
[-] SyncLock.php
[edit]
[-] class-wpml-tm-ams-ate-factories.php
[edit]
[+]
API
[-] JobRecords.php
[edit]
[-] TranslateEverything.php
[edit]
[+]
Review
[-] Jobs.php
[edit]