예제 #1
0
 /**
  * Make an estimation on performance
  * @param array $job_stats
  *
  * @return array
  */
 protected static function _performanceEstimationTime(array $job_stats)
 {
     $estimation_temp = getLastSegmentIDs($job_stats['id']);
     $estimation_concat = array();
     foreach ($estimation_temp as $sid) {
         $estimation_concat[] = $sid['id_segment'];
     }
     $estimation_seg_ids = implode(",", $estimation_concat);
     if ($estimation_seg_ids) {
         //perform check on performance if single segment are set to check or globally Forced
         // Calculating words per hour and estimated completion
         $estimation_temp = getEQWLastHour($job_stats['id'], $estimation_seg_ids);
         if ($estimation_temp[0]['data_validity'] == 1) {
             $job_stats['WORDS_PER_HOUR'] = number_format($estimation_temp[0]['words_per_hour'], 0, '.', ',');
             // 7.2 hours
             // $job_stats['ESTIMATED_COMPLETION'] = number_format( ($job_stats['DRAFT']+$job_stats['REJECTED'])/$estimation_temp[0]['words_per_hour'],1);
             // 1 h 32 m
             // $job_stats['ESTIMATED_COMPLETION'] = date("G",($job_stats['DRAFT']+$job_stats['REJECTED'])/$estimation_temp[0]['words_per_hour']*3600) . "h " . date("i",($job_stats['DRAFT']+$job_stats['REJECTED'])/$estimation_temp[0]['words_per_hour']*3600) . "m";
             $job_stats['ESTIMATED_COMPLETION'] = date("G\\h i\\m", ($job_stats['DRAFT'] + $job_stats['REJECTED']) / (!empty($estimation_temp[0]['words_per_hour']) ? $estimation_temp[0]['words_per_hour'] : 1) * 3600 - 3600);
         }
     }
     return $job_stats;
 }
예제 #2
0
 public static function getStatsForJob($jid, $replay = false)
 {
     // CASMACAT start
     $job_stats = null;
     if ($replay) {
         $job_stats = getStatsForJobWithoutData($jid);
     } else {
         $job_stats = getStatsForJob($jid);
     }
     $job_stats = $job_stats[0];
     $job_stats['TOTAL_FORMATTED'] = number_format($job_stats['TOTAL'], 0, ".", ",");
     $job_stats['TRANSLATED_FORMATTED'] = number_format($job_stats['TRANSLATED'], 0, ".", ",");
     $job_stats['APPROVED_FORMATTED'] = number_format($job_stats['APPROVED'], 0, ".", ",");
     $job_stats['REJECTED_FORMATTED'] = number_format($job_stats['REJECTED'], 0, ".", ",");
     $job_stats['DRAFT_FORMATTED'] = number_format($job_stats['DRAFT'], 0, ".", ",");
     $job_stats['TODO_FORMATTED'] = number_format($job_stats['DRAFT'] + $job_stats['REJECTED'], 0, ".", ",");
     $job_stats['TRANSLATED_PERC'] = $job_stats['TRANSLATED'] / $job_stats['TOTAL'] * 100;
     $job_stats['APPROVED_PERC'] = $job_stats['APPROVED'] / $job_stats['TOTAL'] * 100;
     $job_stats['REJECTED_PERC'] = $job_stats['REJECTED'] / $job_stats['TOTAL'] * 100;
     $job_stats['DRAFT_PERC'] = $job_stats['DRAFT'] / $job_stats['TOTAL'] * 100;
     $job_stats['TRANSLATED_PERC_FORMATTED'] = number_format($job_stats['TRANSLATED_PERC'], 1, ".", ",");
     $job_stats['APPROVED_PERC_FORMATTED'] = number_format($job_stats['APPROVED_PERC'], 1, ".", ",");
     $job_stats['REJECTED_PERC_FORMATTED'] = number_format($job_stats['REJECTED_PERC'], 1, ".", ",");
     $job_stats['DRAFT_PERC_FORMATTED'] = number_format($job_stats['DRAFT_PERC'], 1, ".", ",");
     $t = 'approved';
     if ($job_stats['TRANSLATED_FORMATTED'] > 0) {
         $t = "translated";
     }
     if ($job_stats['DRAFT_FORMATTED'] > 0) {
         $t = "draft";
     }
     if ($job_stats['REJECTED_FORMATTED'] > 0) {
         $t = "draft";
     }
     $job_stats['DOWNLOAD_STATUS'] = $t;
     // Calculating words per hour and estimated completion
     $estimation_temp = getLastSegmentIDs($jid);
     $estimation_seg_ids = $estimation_temp[0]['estimation_seg_ids'];
     if ($estimation_seg_ids) {
         $estimation_temp = getEQWLastHour($jid, $estimation_seg_ids);
         if ($estimation_temp[0]['data_validity'] == 1) {
             $job_stats['WORDS_PER_HOUR'] = number_format($estimation_temp[0]['words_per_hour'], 0, '.', ',');
             // 7.2 hours
             // $job_stats['ESTIMATED_COMPLETION'] = number_format( ($job_stats['DRAFT']+$job_stats['REJECTED'])/$estimation_temp[0]['words_per_hour'],1);
             // 1 h 32 m
             // $job_stats['ESTIMATED_COMPLETION'] = date("G",($job_stats['DRAFT']+$job_stats['REJECTED'])/$estimation_temp[0]['words_per_hour']*3600) . "h " . date("i",($job_stats['DRAFT']+$job_stats['REJECTED'])/$estimation_temp[0]['words_per_hour']*3600) . "m";
             if ($estimation_temp[0]['words_per_hour'] > 0) {
                 $job_stats['ESTIMATED_COMPLETION'] = date("G\\h i\\m", ($job_stats['DRAFT'] + $job_stats['REJECTED']) / $estimation_temp[0]['words_per_hour'] * 3600 - 3600);
             } else {
                 $job_stats['ESTIMATED_COMPLETION'] = "---";
             }
         }
     }
     return $job_stats;
 }