* Pick code from branch 18.x+bi.
This commit is contained in:
@@ -297,7 +297,7 @@ class baseCalc
|
||||
if(strlen($dateStr) > 10) $dateStr = substr($dateStr, 0, 10);
|
||||
$date = DateTime::createFromFormat('Y-m-d', $dateStr);
|
||||
|
||||
return $date->format('W');
|
||||
return substr($date->format('oW'), -2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$config->metric = new stdclass();
|
||||
$config->metric->scopeList = array('system', 'program', 'product', 'project', 'execution', 'dept', 'user', 'code', 'pipeline');
|
||||
$config->metric->scopeList = array('program', 'project', 'product', 'execution', 'dept', 'user', 'system');
|
||||
$config->metric->objectList = array('program', 'line', 'product', 'project', 'productplan', 'execution', 'release', 'story', 'requirement', 'task', 'bug', 'case', 'user', 'effort', 'doc', 'feedback', 'risk', 'issue', 'review');
|
||||
$config->metric->purposeList = array('scale', 'qc', 'hour', 'cost', 'rate', 'time');
|
||||
$config->metric->dateList = array('year', 'month', 'week', 'day');
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
$config->metric->dateType = array();
|
||||
$config->metric->dateType['count_of_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_doing_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_suspended_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_wait_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_top_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_top_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_top_program'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_top_program'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_top_program'] = 'year';
|
||||
$config->metric->dateType['count_of_line'] = 'nodate';
|
||||
$config->metric->dateType['count_of_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_normal_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_product'] = 'year';
|
||||
$config->metric->dateType['count_of_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_wait_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_doing_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_suspended_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_undelayed_finished_project_which_finished'] = 'nodate';
|
||||
$config->metric->dateType['count_of_delayed_finished_project_which_finished'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_project'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_project'] = 'year';
|
||||
$config->metric->dateType['count_of_undelayed_finished_project_which_annual_started'] = 'year';
|
||||
$config->metric->dateType['count_of_delayed_finished_project_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['count_of_undelayed_finished_project_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_project'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_closed_project'] = 'month';
|
||||
$config->metric->dateType['count_of_annual_finished_project'] = 'year';
|
||||
$config->metric->dateType['estimate_of_annual_closed_project'] = 'year';
|
||||
$config->metric->dateType['consume_of_annual_closed_project'] = 'year';
|
||||
$config->metric->dateType['consume_of_monthly_closed_project'] = 'month';
|
||||
$config->metric->dateType['day_of_annual_closed_project'] = 'year';
|
||||
$config->metric->dateType['rate_of_undelayed_finished_project_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['rate_of_delayed_finished_project_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['count_of_productplan'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_productplan'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_finished_productplan'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_productplan'] = 'year';
|
||||
$config->metric->dateType['count_of_finished_productplan'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unfinished_productplan'] = 'nodate';
|
||||
$config->metric->dateType['count_of_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_wait_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_doing_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_suspended_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_execution'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_execution'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_execution'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_closed_execution'] = 'month';
|
||||
$config->metric->dateType['count_of_undelayed_finished_execution_which_finished'] = 'nodate';
|
||||
$config->metric->dateType['count_of_delayed_finished_execution_which_finished'] = 'nodate';
|
||||
$config->metric->dateType['count_of_undelayed_finished_execution_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['count_of_delayed_finished_execution_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['rate_of_undelayed_closed_execution_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['rate_of_delayed_closed_execution_which_annual_finished'] = 'year';
|
||||
$config->metric->dateType['count_of_release'] = 'nodate';
|
||||
$config->metric->dateType['count_of_marker_release'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_release'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_release'] = 'month';
|
||||
$config->metric->dateType['count_of_weekly_created_release'] = 'week';
|
||||
$config->metric->dateType['count_of_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_invalid_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_valid_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_delivered_story'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_story'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_finished_story'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_story'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_finished_story'] = 'month';
|
||||
$config->metric->dateType['count_of_annual_delivered_story'] = 'year';
|
||||
$config->metric->dateType['scale_of_story'] = 'nodate';
|
||||
$config->metric->dateType['scale_of_finished_story'] = 'nodate';
|
||||
$config->metric->dateType['scale_of_invalid_story'] = 'nodate';
|
||||
$config->metric->dateType['scale_of_valid_story'] = 'nodate';
|
||||
$config->metric->dateType['scale_of_annual_finished_story'] = 'year';
|
||||
$config->metric->dateType['scale_of_annual_delivered_story'] = 'year';
|
||||
$config->metric->dateType['scale_of_annual_closed_story'] = 'year';
|
||||
$config->metric->dateType['scale_of_monthly_finished_story'] = 'month';
|
||||
$config->metric->dateType['scale_of_monthly_delivered_story'] = 'month';
|
||||
$config->metric->dateType['scale_of_monthly_closed_story'] = 'month';
|
||||
$config->metric->dateType['scale_of_weekly_finished_story'] = 'week';
|
||||
$config->metric->dateType['count_of_weekly_finished_story'] = 'week';
|
||||
$config->metric->dateType['count_of_daily_created_story'] = 'day';
|
||||
$config->metric->dateType['rate_of_finished_story'] = 'nodate';
|
||||
$config->metric->dateType['rate_of_delivered_story'] = 'nodate';
|
||||
$config->metric->dateType['rate_of_annual_finished_story'] = 'year';
|
||||
$config->metric->dateType['rate_of_annual_delivered_story'] = 'year';
|
||||
$config->metric->dateType['count_of_task'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_task'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unfinished_task'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_task'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_task'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_finished_task'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_task'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_finished_task'] = 'month';
|
||||
$config->metric->dateType['estimate_of_task'] = 'nodate';
|
||||
$config->metric->dateType['consume_of_task'] = 'nodate';
|
||||
$config->metric->dateType['left_of_task'] = 'nodate';
|
||||
$config->metric->dateType['count_of_daily_finished_task'] = 'day';
|
||||
$config->metric->dateType['count_of_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_activated_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_resolved_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_fixed_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_valid_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_bug'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_fixed_bug'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_bug'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_fixed_bug'] = 'month';
|
||||
$config->metric->dateType['count_of_daily_closed_bug'] = 'day';
|
||||
$config->metric->dateType['rate_of_fixed_bug'] = 'nodate';
|
||||
$config->metric->dateType['count_of_case'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_case'] = 'year';
|
||||
$config->metric->dateType['count_of_daily_run_case'] = 'day';
|
||||
$config->metric->dateType['count_of_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_user'] = 'year';
|
||||
$config->metric->dateType['hour_of_annual_effort'] = 'year';
|
||||
$config->metric->dateType['day_of_annual_effort'] = 'year';
|
||||
$config->metric->dateType['day_of_daily_effort'] = 'day';
|
||||
$config->metric->dateType['hour_of_daily_effort'] = 'day';
|
||||
$config->metric->dateType['count_of_doc'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_doc'] = 'year';
|
||||
$config->metric->dateType['count_of_feedback'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_feedback'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_feedback'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_feedback'] = 'year';
|
||||
$config->metric->dateType['count_of_codebase'] = 'nodate';
|
||||
$config->metric->dateType['count_of_pipeline'] = 'nodate';
|
||||
$config->metric->dateType['count_of_artifactrepo'] = 'nodate';
|
||||
$config->metric->dateType['count_of_node'] = 'nodate';
|
||||
$config->metric->dateType['count_of_application'] = 'nodate';
|
||||
$config->metric->dateType['count_of_pending_issue'] = 'nodate';
|
||||
$config->metric->dateType['count_of_pending_mergeRequest'] = 'nodate';
|
||||
$config->metric->dateType['count_of_pending_deployment'] = 'nodate';
|
||||
$config->metric->dateType['count_of_productplan_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_productplan_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_finished_productplan_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_release_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_release_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_created_release_in_product'] = 'month';
|
||||
$config->metric->dateType['count_of_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_delivered_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_invalid_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_valid_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_developed_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['case_coverage_of_projected_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_story_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_finished_story_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_delivered_story_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_story_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_monthly_finished_story_in_product'] = 'month';
|
||||
$config->metric->dateType['count_of_projected_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_monthly_delivered_story_in_product'] = 'month';
|
||||
$config->metric->dateType['count_of_projected_story_with_case_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_monthly_closed_story_in_product'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_created_story_in_product'] = 'month';
|
||||
$config->metric->dateType['scale_of_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['scale_of_annual_finished_story_in_product'] = 'year';
|
||||
$config->metric->dateType['scale_of_annual_delivered_story_in_product'] = 'year';
|
||||
$config->metric->dateType['scale_of_annual_closed_story_in_product'] = 'year';
|
||||
$config->metric->dateType['scale_of_monthly_finished_story_in_product'] = 'month';
|
||||
$config->metric->dateType['rate_of_approved_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['rate_of_finish_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['rate_of_delivery_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_requirement_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_requirement_in_product'] = 'year';
|
||||
$config->metric->dateType['bug_concentration_of_developed_story_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_activated_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_effective_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_fixed_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_severity_1_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_severity_2_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_severe_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_bug_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_created_effective_bug_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_fixed_bug_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_daily_created_bug_in_product'] = 'day';
|
||||
$config->metric->dateType['count_of_daily_resolved_bug_in_product'] = 'day';
|
||||
$config->metric->dateType['count_of_daily_closed_bug_in_product'] = 'day';
|
||||
$config->metric->dateType['count_of_monthly_fixed_bug_in_product'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_closed_bug_in_product'] = 'month';
|
||||
$config->metric->dateType['count_of_monthly_created_bug_in_product'] = 'month';
|
||||
$config->metric->dateType['rate_of_fixed_bug_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_case_in_product'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_created_case_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_feedback_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_created_feedback_in_product'] = 'year';
|
||||
$config->metric->dateType['count_of_annual_closed_feedback_in_product'] = 'year';
|
||||
$config->metric->dateType['planned_period_of_project'] = 'nodate';
|
||||
$config->metric->dateType['left_period_of_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_actual_time_in_project'] = 'nodate';
|
||||
$config->metric->dateType['variance_of_time_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_execution_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_suspended_execution_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_doing_execution_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_wait_execution_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_annual_closed_execution_in_project'] = 'year';
|
||||
$config->metric->dateType['count_of_execution_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unclosed_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_invalid_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_valid_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['scale_of_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_annual_finished_story_in_project'] = 'year';
|
||||
$config->metric->dateType['scale_of_annual_finished_story_in_project'] = 'year';
|
||||
$config->metric->dateType['rate_of_finished_story_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_wait_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_doing_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['estimate_of_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['consume_of_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['left_of_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['ev_of_finished_task_in_waterfall'] = 'nodate';
|
||||
$config->metric->dateType['pv_of_task_in_waterfall'] = 'nodate';
|
||||
$config->metric->dateType['progress_of_task_in_project'] = 'nodate';
|
||||
$config->metric->dateType['sv_in_waterfall'] = 'nodate';
|
||||
$config->metric->dateType['cv_in_waterfall'] = 'nodate';
|
||||
$config->metric->dateType['count_of_bug_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_activated_bug_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_closed_bug_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_user_in_project'] = 'nodate';
|
||||
$config->metric->dateType['consume_of_all_in_project'] = 'nodate';
|
||||
$config->metric->dateType['day_of_invested_in_project'] = 'nodate';
|
||||
$config->metric->dateType['ac_of_all_in_waterfall'] = 'nodate';
|
||||
$config->metric->dateType['count_of_opened_risk_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_opened_issue_in_project'] = 'nodate';
|
||||
$config->metric->dateType['count_of_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_invalid_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_valid_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_developed_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['rate_of_finished_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['rate_of_developed_story_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_finished_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_unfinished_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_daily_finished_task_in_execution'] = 'day';
|
||||
$config->metric->dateType['estimate_of_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['consume_of_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['left_of_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['progress_of_task_in_execution'] = 'nodate';
|
||||
$config->metric->dateType['count_of_reviewing_story_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_daily_review_story_in_user'] = 'day';
|
||||
$config->metric->dateType['count_of_pending_story_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_daily_finished_task_in_user'] = 'day';
|
||||
$config->metric->dateType['count_of_assigned_task_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_daily_fixed_bug_in_user'] = 'day';
|
||||
$config->metric->dateType['count_of_assigned_bug_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_assigned_case_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_assigned_feedback_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_reviewing_feedback_in_user'] = 'nodate';
|
||||
$config->metric->dateType['count_of_daily_review_feedback_in_user'] = 'day';
|
||||
$config->metric->dateType['count_of_submitted_code_issues_in_codebase'] = 'nodate';
|
||||
$config->metric->dateType['count_of_resolved_code_issues_in_codebase'] = 'nodate';
|
||||
$config->metric->dateType['count_of_pending_issues_in_codebase'] = 'nodate';
|
||||
$config->metric->dateType['count_of_merged_pull_requests_in_codebase'] = 'nodate';
|
||||
$config->metric->dateType['count_of_code_commits_in_codebase'] = 'nodate';
|
||||
+26
-19
@@ -68,21 +68,24 @@ class metric extends control
|
||||
$allResultData = array();
|
||||
if(!empty($current))
|
||||
{
|
||||
$metric = $this->metric->getByID($current->id);
|
||||
$current = $this->metric->getByID($current->id);
|
||||
|
||||
$result = $this->metric->getResultByCode($metric->code, array(), 'cron', $pager);
|
||||
$allResult = $this->metric->getResultByCode($metric->code, array(), 'cron');
|
||||
$result = $this->metric->getResultByCode($current->code, array(), 'cron', $pager);
|
||||
$allResult = $this->metric->getResultByCode($current->code, array(), 'cron');
|
||||
|
||||
$resultHeader = $this->metric->getViewTableHeader($metric);
|
||||
$resultData = $this->metric->getViewTableData($metric, $result);
|
||||
$allResultData = $this->metric->getViewTableData($metric, $allResult);
|
||||
$resultHeader = $this->metric->getViewTableHeader($current);
|
||||
$resultData = $this->metric->getViewTableData($current, $result);
|
||||
$allResultData = $this->metric->getViewTableData($current, $allResult);
|
||||
}
|
||||
|
||||
list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData);
|
||||
$currentDateType = $current ? $current->dateType : 'nodate';
|
||||
$currentCode = $current ? $current->code : '';
|
||||
$currentScope = $current ? $current->scope : '';
|
||||
list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData, $currentDateType);
|
||||
$this->view->groupHeader = $groupHeader;
|
||||
$this->view->groupData = $groupData;
|
||||
$this->view->dateType = $current ? $this->metric->getDateTypeByCode($current->code) : 'nodate';
|
||||
$this->view->dateLabels = $this->metric->getDateLabels($this->view->dateType);
|
||||
$this->view->dateType = $currentDateType;
|
||||
$this->view->dateLabels = $this->metric->getDateLabels($currentDateType);
|
||||
$this->view->defaultDate = $this->metric->getDefaultDate($this->view->dateLabels);
|
||||
$this->view->tableWidth = $this->metricZen->getViewTableWidth($groupHeader);
|
||||
$this->view->pagerExtra = $this->metricZen->getPagerExtra($this->view->tableWidth);
|
||||
@@ -101,7 +104,9 @@ class metric extends control
|
||||
$this->view->dtablePager = $pager;
|
||||
$this->view->chartTypeList = $this->metric->getChartTypeList($resultHeader);
|
||||
$this->view->echartOptions = $this->metric->getEchartsOptions($resultHeader, $allResultData);
|
||||
$this->view->metricRecordType = $this->metric->getMetricRecordType($resultHeader);
|
||||
$this->view->metricRecordType = $this->metric->getMetricRecordType($currentCode, $currentScope);
|
||||
$this->view->noDataTip = $this->metric->getNoDataTip($currentCode);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -164,7 +169,6 @@ class metric extends control
|
||||
{
|
||||
// 保存当前的错误报告级别和显示错误的设置
|
||||
$originalDebug = $this->config->debug;
|
||||
$isFirstGenerate = $this->metric->isFirstGenerate();
|
||||
|
||||
// 开启调试模式
|
||||
$this->config->debug = 2;
|
||||
@@ -175,6 +179,7 @@ class metric extends control
|
||||
foreach($classifiedCalcGroup as $calcGroup)
|
||||
{
|
||||
if($this->config->edition == 'open' and in_array($calcGroup->dataset, array('getFeedbacks', 'getIssues', 'getRisks'))) continue;
|
||||
if($this->config->edition == 'biz' and in_array($calcGroup->dataset, array('getIssues', 'getRisks'))) continue;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -184,8 +189,8 @@ class metric extends control
|
||||
$rows = $statement->fetchAll();
|
||||
$this->metricZen->calcMetric($rows, $calcGroup->calcList);
|
||||
|
||||
$records = $this->metricZen->prepareMetricRecord($calcGroup->calcList, $isFirstGenerate);
|
||||
$this->metric->insertMetricLib($records);
|
||||
$recordWithCode = $this->metricZen->prepareMetricRecord($calcGroup->calcList);
|
||||
$this->metric->insertMetricLib($recordWithCode);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
@@ -299,17 +304,18 @@ class metric extends control
|
||||
$resultData = $this->metric->getViewTableData($metric, $result);
|
||||
$allResultData = $this->metric->getViewTableData($metric, $allResult);
|
||||
|
||||
list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData);
|
||||
$dateType = $metric->dateType;
|
||||
list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData, $dateType);
|
||||
$this->view->groupHeader = $groupHeader;
|
||||
$this->view->groupData = $groupData;
|
||||
$this->view->dateType = $this->metric->getDateTypeByCode($metric->code);
|
||||
$this->view->dateLabels = $this->metric->getDateLabels($this->view->dateType);
|
||||
$this->view->dateType = $dateType;
|
||||
$this->view->dateLabels = $this->metric->getDateLabels($dateType);
|
||||
$this->view->defaultDate = $this->metric->getDefaultDate($this->view->dateLabels);
|
||||
$this->view->tableWidth = $this->metricZen->getViewTableWidth($groupHeader);
|
||||
$this->view->pagerExtra = $this->metricZen->getPagerExtra($this->view->tableWidth);
|
||||
$this->view->headerGroup = $this->metric->isHeaderGroup($groupHeader);
|
||||
$this->view->dtablePager = $pager;
|
||||
$this->view->metricRecordType = $this->metric->getMetricRecordType($resultHeader);
|
||||
$this->view->metricRecordType = $this->metric->getMetricRecordType($metric->code, $metric->scope);
|
||||
|
||||
$this->view->metric = $metric;
|
||||
$this->view->chartTypeList = $this->metric->getChartTypeList($resultHeader);
|
||||
@@ -333,18 +339,19 @@ class metric extends control
|
||||
$allResultData = $this->metric->getViewTableData($metric, $allResult);
|
||||
if($usePager) $this->view->dtablePager = $pager;
|
||||
|
||||
list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData);
|
||||
list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData, $metric->dateType);
|
||||
$this->view->groupHeader = $groupHeader;
|
||||
$this->view->groupData = $groupData;
|
||||
$this->view->tableWidth = $this->metricZen->getViewTableWidth($groupHeader);
|
||||
$this->view->pagerExtra = $this->metricZen->getPagerExtra($this->view->tableWidth);
|
||||
$this->view->headerGroup = $this->metric->isHeaderGroup($groupHeader);
|
||||
$this->view->metricRecordType = $this->metric->getMetricRecordType($resultHeader);
|
||||
$this->view->metricRecordType = $this->metric->getMetricRecordType($metric->code, $metric->scope);
|
||||
|
||||
$this->view->viewType = $viewType;
|
||||
$this->view->metric = $metric;
|
||||
$this->view->chartTypeList = $this->metric->getChartTypeList($resultHeader);
|
||||
$this->view->echartOptions = $this->metric->getEchartsOptions($resultHeader, $allResultData);
|
||||
$this->view->noDataTip = $this->metric->getNoDataTip($metric->code);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ i.star {color: var(--color-warning-300);}
|
||||
.table-and-chart .table-side {flex-shrink: 1; max-width: 50%; border-style: solid; border-width: 1px 0px 1px 1px; border-color: var(--color-gray-300);}
|
||||
.table-and-chart .chart-side {flex-grow: 1; border: 1px solid var(--color-gray-300); padding: 20px;}
|
||||
.table-and-chart .chart-center {display:flex; justify-content: center; align-items: center;}
|
||||
.table-and-chart.no-data {justify-content: center; align-items: center;}
|
||||
.table-and-chart.no-data span {color: var(--color-gray-400);}
|
||||
|
||||
.icon-18 {font-size: 18px;}
|
||||
.primary-hover-500 {color: var(--color-gray-800)}
|
||||
|
||||
@@ -124,6 +124,10 @@ $lang->metric->noFormula = "No calculation rules available";
|
||||
$lang->metric->noCalc = "The PHP algorithm for this metric has not been implemented yet";
|
||||
$lang->metric->noSQL = "No SQL";
|
||||
|
||||
$lang->metric->noData = "No data available.";
|
||||
$lang->metric->noDataBeforeCollect = "No data is available until the time for data collection.";
|
||||
$lang->metric->noDataAfterCollect = "No data is available after the time for data collection.";
|
||||
|
||||
$lang->metric->legendBasicInfo = 'Basic Information';
|
||||
$lang->metric->legendCreateInfo = 'Creation and Editing Information';
|
||||
|
||||
@@ -155,8 +159,8 @@ $lang->metric->featureBar['preview']['dept'] = 'Team';
|
||||
$lang->metric->featureBar['preview']['user'] = 'Individual';
|
||||
$lang->metric->featureBar['preview']['program'] = 'Program';
|
||||
$lang->metric->featureBar['preview']['system'] = 'System';
|
||||
$lang->metric->featureBar['preview']['code'] = 'Code Repository';
|
||||
$lang->metric->featureBar['preview']['pipeline'] = 'Pipeline';
|
||||
// $lang->metric->featureBar['preview']['code'] = 'Code Repository';
|
||||
// $lang->metric->featureBar['preview']['pipeline'] = 'Pipeline';
|
||||
|
||||
$lang->metric->more = 'More';
|
||||
$lang->metric->collect = 'My Collect';
|
||||
@@ -204,8 +208,8 @@ $lang->metric->scopeList['project'] = "Project";
|
||||
$lang->metric->scopeList['execution'] = "Execution";
|
||||
$lang->metric->scopeList['dept'] = "Team";
|
||||
$lang->metric->scopeList['user'] = "Individual";
|
||||
$lang->metric->scopeList['code'] = "Code Repository";
|
||||
$lang->metric->scopeList['pipeline'] = "Pipeline";
|
||||
// $lang->metric->scopeList['code'] = "Code Repository";
|
||||
// $lang->metric->scopeList['pipeline'] = "Pipeline";
|
||||
$lang->metric->scopeList['other'] = "Other";
|
||||
|
||||
global $config;
|
||||
|
||||
@@ -124,6 +124,10 @@ $lang->metric->noFormula = "No calculation rules available";
|
||||
$lang->metric->noCalc = "The PHP algorithm for this metric has not been implemented yet";
|
||||
$lang->metric->noSQL = "No SQL";
|
||||
|
||||
$lang->metric->noData = "No data available.";
|
||||
$lang->metric->noDataBeforeCollect = "No data is available until the time for data collection.";
|
||||
$lang->metric->noDataAfterCollect = "No data is available after the time for data collection.";
|
||||
|
||||
$lang->metric->legendBasicInfo = 'Basic Information';
|
||||
$lang->metric->legendCreateInfo = 'Creation and Editing Information';
|
||||
|
||||
@@ -155,8 +159,8 @@ $lang->metric->featureBar['preview']['dept'] = 'Team';
|
||||
$lang->metric->featureBar['preview']['user'] = 'Individual';
|
||||
$lang->metric->featureBar['preview']['program'] = 'Program';
|
||||
$lang->metric->featureBar['preview']['system'] = 'System';
|
||||
$lang->metric->featureBar['preview']['code'] = 'Code Repository';
|
||||
$lang->metric->featureBar['preview']['pipeline'] = 'Pipeline';
|
||||
// $lang->metric->featureBar['preview']['code'] = 'Code Repository';
|
||||
// $lang->metric->featureBar['preview']['pipeline'] = 'Pipeline';
|
||||
|
||||
$lang->metric->more = 'More';
|
||||
$lang->metric->collect = 'My Collect';
|
||||
@@ -204,8 +208,8 @@ $lang->metric->scopeList['project'] = "Project";
|
||||
$lang->metric->scopeList['execution'] = "Execution";
|
||||
$lang->metric->scopeList['dept'] = "Team";
|
||||
$lang->metric->scopeList['user'] = "Individual";
|
||||
$lang->metric->scopeList['code'] = "Code Repository";
|
||||
$lang->metric->scopeList['pipeline'] = "Pipeline";
|
||||
// $lang->metric->scopeList['code'] = "Code Repository";
|
||||
// $lang->metric->scopeList['pipeline'] = "Pipeline";
|
||||
$lang->metric->scopeList['other'] = "Other";
|
||||
|
||||
global $config;
|
||||
|
||||
@@ -124,6 +124,10 @@ $lang->metric->noFormula = "No calculation rules available";
|
||||
$lang->metric->noCalc = "The PHP algorithm for this metric has not been implemented yet";
|
||||
$lang->metric->noSQL = "No SQL";
|
||||
|
||||
$lang->metric->noData = "No data available.";
|
||||
$lang->metric->noDataBeforeCollect = "No data is available until the time for data collection.";
|
||||
$lang->metric->noDataAfterCollect = "No data is available after the time for data collection.";
|
||||
|
||||
$lang->metric->legendBasicInfo = 'Basic Information';
|
||||
$lang->metric->legendCreateInfo = 'Creation and Editing Information';
|
||||
|
||||
@@ -155,8 +159,8 @@ $lang->metric->featureBar['preview']['dept'] = 'Team';
|
||||
$lang->metric->featureBar['preview']['user'] = 'Individual';
|
||||
$lang->metric->featureBar['preview']['program'] = 'Program';
|
||||
$lang->metric->featureBar['preview']['system'] = 'System';
|
||||
$lang->metric->featureBar['preview']['code'] = 'Code Repository';
|
||||
$lang->metric->featureBar['preview']['pipeline'] = 'Pipeline';
|
||||
// $lang->metric->featureBar['preview']['code'] = 'Code Repository';
|
||||
// $lang->metric->featureBar['preview']['pipeline'] = 'Pipeline';
|
||||
|
||||
$lang->metric->more = 'More';
|
||||
$lang->metric->collect = 'My Collect';
|
||||
@@ -204,8 +208,8 @@ $lang->metric->scopeList['project'] = "Project";
|
||||
$lang->metric->scopeList['execution'] = "Execution";
|
||||
$lang->metric->scopeList['dept'] = "Team";
|
||||
$lang->metric->scopeList['user'] = "Individual";
|
||||
$lang->metric->scopeList['code'] = "Code Repository";
|
||||
$lang->metric->scopeList['pipeline'] = "Pipeline";
|
||||
// $lang->metric->scopeList['code'] = "Code Repository";
|
||||
// $lang->metric->scopeList['pipeline'] = "Pipeline";
|
||||
$lang->metric->scopeList['other'] = "Other";
|
||||
|
||||
global $config;
|
||||
|
||||
@@ -124,6 +124,10 @@ $lang->metric->noFormula = "暂无计算规则";
|
||||
$lang->metric->noCalc = "暂未实现度量项PHP算法";
|
||||
$lang->metric->noSQL = "暂无";
|
||||
|
||||
$lang->metric->noData = "暂时没有数据。";
|
||||
$lang->metric->noDataBeforeCollect = "未到收集数据的时间,暂无数据。";
|
||||
$lang->metric->noDataAfterCollect = "度量范围内未产生数据,暂无数据。";
|
||||
|
||||
$lang->metric->legendBasicInfo = '基本信息';
|
||||
$lang->metric->legendCreateInfo = '创建编辑信息';
|
||||
|
||||
@@ -155,8 +159,8 @@ $lang->metric->featureBar['preview']['dept'] = '团队';
|
||||
$lang->metric->featureBar['preview']['user'] = '个人';
|
||||
$lang->metric->featureBar['preview']['program'] = '项目集';
|
||||
$lang->metric->featureBar['preview']['system'] = '系统';
|
||||
$lang->metric->featureBar['preview']['code'] = '代码库';
|
||||
$lang->metric->featureBar['preview']['pipeline'] = '流水线';
|
||||
// $lang->metric->featureBar['preview']['code'] = '代码库';
|
||||
// $lang->metric->featureBar['preview']['pipeline'] = '流水线';
|
||||
|
||||
$lang->metric->more = '更多';
|
||||
$lang->metric->collect = '我收藏的';
|
||||
@@ -204,8 +208,8 @@ $lang->metric->scopeList['project'] = "项目";
|
||||
$lang->metric->scopeList['execution'] = "执行";
|
||||
$lang->metric->scopeList['dept'] = "团队";
|
||||
$lang->metric->scopeList['user'] = "个人";
|
||||
$lang->metric->scopeList['code'] = "代码库";
|
||||
$lang->metric->scopeList['pipeline'] = "流水线";
|
||||
// $lang->metric->scopeList['code'] = "代码库";
|
||||
// $lang->metric->scopeList['pipeline'] = "流水线";
|
||||
$lang->metric->scopeList['other'] = "其他";
|
||||
|
||||
global $config;
|
||||
|
||||
@@ -77,8 +77,8 @@ $lang->metric->scopeList['project'] = "專案";
|
||||
$lang->metric->scopeList['execution'] = "執行";
|
||||
$lang->metric->scopeList['dept'] = "團隊";
|
||||
$lang->metric->scopeList['user'] = "個人";
|
||||
$lang->metric->scopeList['code'] = "程式庫";
|
||||
$lang->metric->scopeList['pipeline'] = "流水線";
|
||||
// $lang->metric->scopeList['code'] = "程式庫";
|
||||
// $lang->metric->scopeList['pipeline'] = "流水線";
|
||||
|
||||
global $config;
|
||||
$lang->metric->objectList = array();
|
||||
|
||||
+205
-91
@@ -69,10 +69,11 @@ class metricModel extends model
|
||||
*/
|
||||
public function getViewTableData($metric, $result)
|
||||
{
|
||||
$scope = $metric->scope;
|
||||
if(empty($result)) return array();
|
||||
|
||||
if($metric->scope != 'system') $objectPairs = $this->getPairsByScope($scope);
|
||||
$scope = $metric->scope;
|
||||
$dateType = $metric->dateType;
|
||||
if($scope != 'system') $objectPairs = $this->getPairsByScope($scope);
|
||||
|
||||
$tableData = array();
|
||||
foreach($result as $record)
|
||||
@@ -80,8 +81,6 @@ class metricModel extends model
|
||||
$record = (array)$record;
|
||||
if(isset($record['date'])) $record['calcTime'] = date("Y-m-d H:i", strtotime($record['date']));
|
||||
|
||||
$dateType = $this->getDateType(array_keys($record));
|
||||
|
||||
$row = $this->buildDateCell($record, $dateType);
|
||||
if($scope != 'system')
|
||||
{
|
||||
@@ -106,7 +105,7 @@ class metricModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupTable($header, $data, $withCalcTime = true)
|
||||
public function getGroupTable($header, $data, $dateType, $withCalcTime = true)
|
||||
{
|
||||
if(!$header or !$data) return array(array(), array());
|
||||
|
||||
@@ -114,23 +113,21 @@ class metricModel extends model
|
||||
|
||||
if($headerLength == 2)
|
||||
{
|
||||
return $this->getTimeTable($data, 'nodate', $withCalcTime);
|
||||
return $this->getTimeTable($data, $dateType, $withCalcTime); // $dateType should eq nodate
|
||||
}
|
||||
elseif($headerLength == 3)
|
||||
{
|
||||
if($this->isObjectMetric($header))
|
||||
{
|
||||
return $this->getObjectTable($header, $data, 'nodate', $withCalcTime);
|
||||
return $this->getObjectTable($header, $data, $dateType, $withCalcTime); // $dateType should eq nodate
|
||||
}
|
||||
else
|
||||
{
|
||||
$dateType = current($data)->dateType;
|
||||
return $this->getTimeTable($data, $dateType, $withCalcTime);
|
||||
}
|
||||
}
|
||||
elseif($headerLength == 4)
|
||||
{
|
||||
$dateType = current($data)->dateType;
|
||||
return $this->getObjectTable($header, $data, $dateType, $withCalcTime);
|
||||
}
|
||||
|
||||
@@ -199,16 +196,16 @@ class metricModel extends model
|
||||
return array($groupHeader, $groupData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建有对象属性的度量项的表格数据。
|
||||
* Build table data for metric with object.
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $dateType
|
||||
* @param bool $withCalcTime
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
* 构建有对象属性的度量项的表格数据。
|
||||
* Build table data for metric with object.
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $dateType
|
||||
* @param bool $withCalcTime
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getObjectTable($header, $data, $dateType = 'day', $withCalcTime = true)
|
||||
{
|
||||
$groupHeader = array();
|
||||
@@ -507,6 +504,7 @@ class metricModel extends model
|
||||
$metric->collectConf = $oldMetric->collectConf;
|
||||
$metric->execTime = $oldMetric->execTime;
|
||||
}
|
||||
if(empty($metric->dateType) and isset($metric->code)) $metric->dateType = $this->getDateTypeByCode($metric->code);
|
||||
|
||||
return $metric;
|
||||
}
|
||||
@@ -515,7 +513,7 @@ class metricModel extends model
|
||||
* 根据ID获取旧版度量项信息。
|
||||
* Get old metric info by id.
|
||||
*
|
||||
* @param int $measurementID
|
||||
* @param int $measurementID
|
||||
* @access public
|
||||
* @return object|false
|
||||
*/
|
||||
@@ -545,6 +543,28 @@ class metricModel extends model
|
||||
return $measurement;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取dao对象。
|
||||
* Get dao object.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getDAO()
|
||||
{
|
||||
if($this->config->metricDB->type == 'sqlite')
|
||||
{
|
||||
$dao = clone $this->dao;
|
||||
$dao->reset();
|
||||
|
||||
$dao->dbh = $this->app->connectSqlite();
|
||||
$dao->driver = 'sqlite';
|
||||
|
||||
return $dao;
|
||||
}
|
||||
return $this->dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取度量项数据源句柄。
|
||||
* Get data source statement of calculator.
|
||||
@@ -556,11 +576,12 @@ class metricModel extends model
|
||||
*/
|
||||
public function getDataStatement($calculator, $returnType = 'statement')
|
||||
{
|
||||
$dao = $this->getDAO();
|
||||
if(!empty($calculator->dataset))
|
||||
{
|
||||
include_once $this->getDatasetPath();
|
||||
|
||||
$dataset = new dataset($this->dao);
|
||||
$dataset = new dataset($dao);
|
||||
$dataSource = $calculator->dataset;
|
||||
$fieldList = implode(',', $calculator->fieldList);
|
||||
|
||||
@@ -569,7 +590,7 @@ class metricModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
$calculator->setDAO($this->dao);
|
||||
$calculator->setDAO($dao);
|
||||
$scm = $this->app->loadClass('scm');
|
||||
$calculator->setSCM($scm);
|
||||
|
||||
@@ -585,10 +606,10 @@ class metricModel extends model
|
||||
* Get date field of metric data.
|
||||
*
|
||||
* @param string $code
|
||||
* @access public
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
public function getMetricRecordDateField(string $code): array
|
||||
protected function getMetricRecordDateField(string $code): array
|
||||
{
|
||||
$record = $this->dao->select("year, month, week, day")
|
||||
->from(TABLE_METRICLIB)
|
||||
@@ -639,7 +660,7 @@ class metricModel extends model
|
||||
*
|
||||
* @param string $code
|
||||
* @param array $options e.g. array('product' => '1,2,3', 'year' => '2023')
|
||||
* @param string $type cron|realtime
|
||||
* @param string $type
|
||||
* @param object|null $pager
|
||||
* @access public
|
||||
* @return array
|
||||
@@ -725,7 +746,9 @@ class metricModel extends model
|
||||
*/
|
||||
public function deduplication(string $code): bool
|
||||
{
|
||||
$metric = $this->getByCode($code);
|
||||
$fields = $this->metricTao->getRecordFields($code);
|
||||
if(!in_array($metric->scope, $fields)) $fields[] = $metric->scope;
|
||||
|
||||
if(empty($fields)) return false;
|
||||
|
||||
@@ -787,36 +810,33 @@ class metricModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为第一次生成度量数据。
|
||||
* Whether it is the first time to generate metric data.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function isFirstGenerate(): bool
|
||||
{
|
||||
$record = $this->dao->select('id')->from(TABLE_METRICLIB)->limit(1)->fetch();
|
||||
|
||||
return !$record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入度量库数据。
|
||||
* Insert into metric lib.
|
||||
*
|
||||
* @param array $records
|
||||
* @param array $recordWithCode
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function insertMetricLib($records)
|
||||
public function insertMetricLib($recordWithCode)
|
||||
{
|
||||
$this->dao->begin();
|
||||
foreach($records as $record)
|
||||
foreach($recordWithCode as $code => $records)
|
||||
{
|
||||
if(empty($record)) continue;
|
||||
$this->dao->insert(TABLE_METRICLIB)
|
||||
->data($record)
|
||||
foreach($records as $record)
|
||||
{
|
||||
if(empty($record)) continue;
|
||||
$this->dao->insert(TABLE_METRICLIB)
|
||||
->data($record)
|
||||
->exec();
|
||||
}
|
||||
$rows = count($records);
|
||||
$time = helper::now();
|
||||
|
||||
$this->dao->update(TABLE_METRIC)
|
||||
->set('lastCalcRows')->eq($rows)
|
||||
->set('lastCalcTime')->eq($time)
|
||||
->where('code')->eq($code)
|
||||
->exec();
|
||||
}
|
||||
$this->dao->commit();
|
||||
@@ -898,11 +918,11 @@ class metricModel extends model
|
||||
* @access public
|
||||
* @return dataset
|
||||
*/
|
||||
public function getDataset()
|
||||
public function getDataset($dao)
|
||||
{
|
||||
$datasetPath = $this->getDatasetPath();
|
||||
include_once $datasetPath;
|
||||
return new dataset($this->dao);
|
||||
return new dataset($dao);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -953,13 +973,19 @@ class metricModel extends model
|
||||
$aliasList = array();
|
||||
foreach($uniqueList as $field)
|
||||
{
|
||||
if(strpos($field, '.') === false || strpos(strtoupper($field), ' AS ') !== false)
|
||||
if(strpos(strtoupper($field), ' AS ') !== false)
|
||||
{
|
||||
$aliasList[] = $field;
|
||||
continue;
|
||||
}
|
||||
$alias = str_replace('.', '_', $field);
|
||||
$aliasList[] = $field . ' AS ' . $alias;
|
||||
if(strpos($field, '.') !== false)
|
||||
{
|
||||
$alias = str_replace('.', '_', $field);
|
||||
list($table, $field) = explode('.', $field);
|
||||
$aliasList[] = "`$table`.`$field` AS `$alias`";
|
||||
continue;
|
||||
}
|
||||
$aliasList[] = "`$field`";
|
||||
}
|
||||
return implode(',', $aliasList);
|
||||
}
|
||||
@@ -1027,12 +1053,15 @@ class metricModel extends model
|
||||
* Get object pairs by scope.
|
||||
*
|
||||
* @param string $scope
|
||||
* @param bool $withHierarchy
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPairsByScope($scope)
|
||||
public function getPairsByScope($scope, $withHierarchy = false)
|
||||
{
|
||||
if(empty($scope) || $scope == 'system') return array();
|
||||
if($scope == 'dept' && $withHierarchy) $scope = 'deptWithHierarchy';
|
||||
if($scope == 'program' && $withHierarchy) $scope = 'programWithHierarchy';
|
||||
|
||||
$objectPairs = array();
|
||||
switch($scope)
|
||||
@@ -1040,8 +1069,11 @@ class metricModel extends model
|
||||
case 'dept':
|
||||
$objectPairs = $this->loadModel('dept')->getDeptPairs();
|
||||
break;
|
||||
case 'deptWithHierarchy':
|
||||
$objectPairs = $this->loadModel('dept')->getOptionMenu();
|
||||
break;
|
||||
case 'user':
|
||||
$objectPairs = $this->loadModel('user')->getPairs('noletter');
|
||||
$objectPairs = $this->loadModel('user')->getPairs('noletter|noempty|noclosed');
|
||||
break;
|
||||
case 'program':
|
||||
$objectPairs = $this->dao->select('id, name')->from(TABLE_PROGRAM)
|
||||
@@ -1049,9 +1081,14 @@ class metricModel extends model
|
||||
->andWhere('type')->eq('program')
|
||||
->fetchPairs();
|
||||
break;
|
||||
case 'programWithHierarchy':
|
||||
$objectPairs = $this->loadModel('program')->getParentPairs();
|
||||
break;
|
||||
case 'product':
|
||||
$objectPairs = $this->dao->select('id, name')->from(TABLE_PRODUCT)
|
||||
->where('deleted')->eq(0)->fetchPairs();
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('shadow')->eq(0)
|
||||
->fetchPairs();
|
||||
break;
|
||||
case 'project':
|
||||
$objectPairs = $this->dao->select('id, name')->from(TABLE_PROJECT)
|
||||
@@ -1083,7 +1120,7 @@ class metricModel extends model
|
||||
* @param array $record
|
||||
* @param string $dateType
|
||||
* @access public
|
||||
* @return string
|
||||
* @return object
|
||||
*/
|
||||
public function buildDateCell($record, $dateType)
|
||||
{
|
||||
@@ -1289,7 +1326,7 @@ class metricModel extends model
|
||||
*/
|
||||
public function isOldMetric($metric)
|
||||
{
|
||||
return isset($metric->type) and $metric->type == 'sql';
|
||||
return $metric->type == 'sql';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1547,16 +1584,17 @@ class metricModel extends model
|
||||
* @access public
|
||||
* @return string|false
|
||||
*/
|
||||
public function getMetricRecordType(array|bool $tableData): string|false
|
||||
public function getMetricRecordType($code, $scope)
|
||||
{
|
||||
if(!$tableData) return false;
|
||||
$fields = array_column($tableData, 'name');
|
||||
if(!$code) return false;
|
||||
|
||||
$type = array();
|
||||
if(in_array('scope', $fields)) $type[] = 'scope';
|
||||
if(in_array('date', $fields)) $type[] = 'date';
|
||||
$dateType = $this->getDateTypeByCode($code);
|
||||
|
||||
if($scope != 'system') $type[] = 'scope';
|
||||
if($dateType != 'nodate') $type[] = 'date';
|
||||
if(empty($type)) $type[] = 'system';
|
||||
|
||||
return implode('-', $type);
|
||||
}
|
||||
|
||||
@@ -1616,25 +1654,6 @@ class metricModel extends model
|
||||
return in_array('date', array_column($header, 'name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是按系统统计的度量项。
|
||||
* Determine whether it is metric in system.
|
||||
*
|
||||
* @param array $results
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function isSystemMetric($results)
|
||||
{
|
||||
$firstRecord = (object)current($results);
|
||||
|
||||
foreach($this->config->metric->excludeGlobal as $exclude)
|
||||
{
|
||||
if(isset($firstRecord->$exclude)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个echarts的配置项。
|
||||
* Get options of echarts by head and data.
|
||||
@@ -1992,6 +2011,35 @@ class metricModel extends model
|
||||
return $query[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期类型和日期,拆解出日期的年、月、周、日。
|
||||
* Get date values by date type and date.
|
||||
*
|
||||
* @param string $date
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function generateDateValues($date)
|
||||
{
|
||||
$timestamp = strtotime($date);
|
||||
|
||||
$year = date('Y', $timestamp);
|
||||
$month = date('m', $timestamp);
|
||||
$day = date('d', $timestamp);
|
||||
$week = date('oW', $timestamp);
|
||||
$week = substr($week, -2);
|
||||
|
||||
$dateValues = new stdClass();
|
||||
|
||||
$dateValues->year = array('year' => $year);
|
||||
$dateValues->month = array('year' => $year, 'month' => $month);
|
||||
$dateValues->week = array('year' => $year, 'week' => $week);
|
||||
$dateValues->day = array('year' => $year, 'month' => $month, 'day' => $day);
|
||||
$dateValues->nodate = array();
|
||||
|
||||
return $dateValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取度量数据的日期类型。
|
||||
* Get date type of metric data.
|
||||
@@ -2012,20 +2060,36 @@ class metricModel extends model
|
||||
return 'nodate';
|
||||
}
|
||||
|
||||
public function getDateTypeByCode(string $code)
|
||||
{
|
||||
/* Get dateType form db first. */
|
||||
$metric = $this->getByCode($code, 'dateType');
|
||||
if(!empty($metric->dateType)) return $metric->dateType;
|
||||
|
||||
/* Get dateType from config second. */
|
||||
if(isset($this->config->metric->dateType[$code])) return $this->config->metric->dateType[$code];
|
||||
|
||||
/* At last, infer dateType by code. */
|
||||
$dataFields = $this->getMetricRecordDateField($code);
|
||||
return $this->getDateType($dataFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据代号获取度量数据的日期类型。
|
||||
* Get date type of metric by code.
|
||||
* 获取度量数据的日期类型。
|
||||
* Get date type of metric data.
|
||||
*
|
||||
* @param string $code
|
||||
* @param array $dateFields
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDateTypeByCode(string $code)
|
||||
public function getDateByDateType(string $dateType): string
|
||||
{
|
||||
$dataFields = $this->getMetricRecordDateField($code);
|
||||
$dateType = $this->getDateType($dataFields);
|
||||
if($dateType == 'day') $sub = '-7 days';
|
||||
if($dateType == 'week') $sub = '-1 month';
|
||||
if($dateType == 'month') $sub = '-1 year';
|
||||
if($dateType == 'year') $sub = '-3 years';
|
||||
|
||||
return $dateType;
|
||||
return date('Y-m-d', strtotime($sub));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2069,11 +2133,11 @@ class metricModel extends model
|
||||
* 判断 header 是否有分组(合并单元格)。
|
||||
* Judge header whether there are merges cell.
|
||||
*
|
||||
* @param array $header
|
||||
* @access public
|
||||
* @param array $header
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
public function isHeaderGroup($header)
|
||||
protected function isHeaderGroup($header)
|
||||
{
|
||||
if(!$header) return false;
|
||||
|
||||
@@ -2085,6 +2149,25 @@ class metricModel extends model
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是按系统统计的度量项。
|
||||
* Determine whether it is metric in system.
|
||||
*
|
||||
* @param array $results
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function isSystemMetric($results)
|
||||
{
|
||||
$firstRecord = (object)current($results);
|
||||
|
||||
foreach($this->config->metric->excludeGlobal as $exclude)
|
||||
{
|
||||
if(isset($firstRecord->$exclude)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取度量项的收集周期。
|
||||
* Get collect cycle of metric.
|
||||
@@ -2126,11 +2209,42 @@ class metricModel extends model
|
||||
* Get default selected date.
|
||||
*
|
||||
* @param array $dateLabels
|
||||
* @param array $filters
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDate(array $dateLabels): string
|
||||
public function getDefaultDate(array $dateLabels, array $filters = array()): string
|
||||
{
|
||||
return (string)current(array_keys($dateLabels));
|
||||
$defaultDate = '';
|
||||
|
||||
$dates = array_keys($dateLabels);
|
||||
return (string)current($dates);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取没有数据时的提示信息。
|
||||
* Get no data tip.
|
||||
*
|
||||
* @param string $code
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getNoDataTip($code)
|
||||
{
|
||||
$today = helper::today();
|
||||
|
||||
$todayData = $this->metricTao->fetchMetricRecordByDate('all', $today, 1);
|
||||
$todayDataWithCode = $this->metricTao->fetchMetricRecordByDate($code, $today, 1);
|
||||
$dataWithCode = $this->metricTao->fetchMetricRecordByDate($code, null, 1);
|
||||
|
||||
/* 度量项定义之后,未到采集时间,可以理解为今天没有任何数据并且该度量项没有任何数据。*/
|
||||
/* After the metric item is defined, it is not time to collect, which can be understood as there is no data today and the metric item has no data. */
|
||||
if(empty($todayData) && empty($dataWithCode)) return $this->lang->metric->noDataBeforeCollect;
|
||||
|
||||
/* 度量项定义之后,已到采集时间,但是没有采集到数据,可以理解为今天收集到了数据但是该度量项没有任何数据。*/
|
||||
/* After the metric item is defined, it is time to collect, but no data is collected, which can be understood as data is collected today, but the metric item has no data. */
|
||||
if(!empty($todayData) && empty($dataWithCode)) return $this->lang->metric->noDataAfterCollect;
|
||||
|
||||
return $this->lang->metric->noData;
|
||||
}
|
||||
}
|
||||
|
||||
+31
-8
@@ -117,7 +117,7 @@ class metricTao extends metricModel
|
||||
* 根据筛选条件获取度量项数据。
|
||||
* Fetch metric by filter.
|
||||
*
|
||||
* @param array $filters
|
||||
* @param array $filters
|
||||
* @param string $stage
|
||||
* @access protected
|
||||
* @return array
|
||||
@@ -139,6 +139,7 @@ class metricTao extends metricModel
|
||||
->beginIF(!empty($objects))->andWhere('object')->in($objects)->fi()
|
||||
->beginIF(!empty($purposes))->andWhere('purpose')->in($purposes)->fi()
|
||||
->beginIF($this->config->edition == 'open')->andWhere('object')->notIN('feedback,issue,risk')
|
||||
->beginIF($this->config->edition == 'biz')->andWhere('object')->notIN('issue,risk')
|
||||
->fetchAll();
|
||||
|
||||
return $metrics;
|
||||
@@ -157,7 +158,7 @@ class metricTao extends metricModel
|
||||
return $this->dao->select('*')->from(TABLE_METRIC)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('collector')->like("%,{$this->app->user->account},%")
|
||||
->beginIF($stage != 'all')->andWhere('stage')->eq($stage)->fi()
|
||||
->beginIF($stage!= 'all')->andWhere('stage')->eq($stage)->fi()
|
||||
->beginIF($this->config->edition == 'open')->andWhere('object')->notIN('feedback,issue,risk')
|
||||
->fetchAll();
|
||||
}
|
||||
@@ -166,7 +167,7 @@ class metricTao extends metricModel
|
||||
* 请求模块数据。
|
||||
* Fetch module data.
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $scope
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
@@ -301,11 +302,33 @@ class metricTao extends metricModel
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期获取度量数据。
|
||||
* Fetch metric record by date.
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $date
|
||||
* @param int $limit
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function fetchMetricRecordByDate($code = 'all', $date = '', $limit = 100)
|
||||
{
|
||||
$records = $this->dao->select('*')->from(TABLE_METRICLIB)
|
||||
->where('1 = 1')
|
||||
->beginIF($code != 'all')->andWhere('metricCode')->eq($code)->fi()
|
||||
->beginIF(!empty($date))->andWhere('left(date, 10)')->eq($date)->fi()
|
||||
->beginIF($limit > 0)->limit($limit)->fi()
|
||||
->fetchAll();
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取度量数据有效字段。
|
||||
* Get metric record fields.
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $code
|
||||
* @access protected
|
||||
* @return array|false
|
||||
*/
|
||||
@@ -317,7 +340,7 @@ class metricTao extends metricModel
|
||||
->limit(1)
|
||||
->fetch();
|
||||
|
||||
if(!$record) return false;
|
||||
if(!$record) return array();
|
||||
|
||||
$fields = array();
|
||||
foreach(array_keys((array)$record) as $field)
|
||||
@@ -350,8 +373,8 @@ class metricTao extends metricModel
|
||||
* 将度量数据不重复的id插入到临时表中。
|
||||
* Insert distinct metric record id to temp table.
|
||||
*
|
||||
* @param string $code
|
||||
* @param array $fields
|
||||
* @param string $code
|
||||
* @param array $fields
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
@@ -361,8 +384,8 @@ class metricTao extends metricModel
|
||||
/**
|
||||
* 判断fields中的字段是否与array('year', 'month', 'week', 'day')存在交集
|
||||
*/
|
||||
foreach($fields as $key => $field) $fields[$key] = "`$field`";
|
||||
$intersect = array_intersect($fields, array('year', 'month', 'week', 'day'));
|
||||
foreach($fields as $key => $field) $fields[$key] = "`$field`";
|
||||
if(empty($intersect)) $fields[] = 'left(date, 10)';
|
||||
|
||||
$sql = "INSERT INTO `metriclib_distinct` (id) ";
|
||||
|
||||
@@ -13,7 +13,7 @@ jsVar('updateTimeTip', $lang->metric->updateTimeTip);
|
||||
|
||||
div
|
||||
(
|
||||
setClass("table-and-chart table-and-chart-{$viewType}"),
|
||||
setClass("table-and-chart table-and-chart-{$viewType}" . ($groupData ? '' : ' no-data')),
|
||||
$groupData ? div
|
||||
(
|
||||
setClass('table-side'),
|
||||
@@ -64,5 +64,6 @@ div
|
||||
set::tooltip($echartOptions['tooltip'])
|
||||
)->size('100%', '100%')
|
||||
)
|
||||
) : null
|
||||
) : null,
|
||||
$groupData ? null : span($noDataTip, setClass('text-md'))
|
||||
);
|
||||
|
||||
@@ -386,7 +386,7 @@ $metricBoxs = div
|
||||
$fnGenerateQueryForm(),
|
||||
div
|
||||
(
|
||||
setClass('table-and-chart table-and-chart-multiple'),
|
||||
setClass('table-and-chart table-and-chart-multiple' . ($groupData ? '' : ' no-data')),
|
||||
$groupData ? div
|
||||
(
|
||||
setClass('table-side'),
|
||||
@@ -436,7 +436,8 @@ $metricBoxs = div
|
||||
set::tooltip($echartOptions['tooltip'])
|
||||
)->size('100%', '100%')
|
||||
)
|
||||
) : null
|
||||
) : null,
|
||||
$groupData ? null : span($noDataTip, setClass('text-md'))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ $fnGenerateSide = function() use($groupMetrics, $current, $viewType, $scope, $la
|
||||
}
|
||||
}
|
||||
|
||||
return ul(setClass('list-unstyled'), $metricList);
|
||||
return ul($metricList);
|
||||
};
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ div
|
||||
$fnGenerateQueryForm(),
|
||||
div
|
||||
(
|
||||
setClass('table-and-chart table-and-chart-single'),
|
||||
setClass('table-and-chart table-and-chart-single' . ($groupData ? '' : ' no-data')),
|
||||
$groupData ? div
|
||||
(
|
||||
setClass('table-side'),
|
||||
@@ -393,7 +393,8 @@ div
|
||||
set::tooltip($echartOptions['tooltip'])
|
||||
)->size('100%', '100%')
|
||||
)
|
||||
) : null
|
||||
) : null,
|
||||
$groupData ? null : span($noDataTip, setClass('text-md'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
+111
-18
@@ -86,18 +86,20 @@ class metricZen extends metric
|
||||
*/
|
||||
protected function prepareDataset($calcGroup)
|
||||
{
|
||||
$dao = $this->metric->getDAO();
|
||||
|
||||
$dataSource = $calcGroup->dataset;
|
||||
$calcList = $calcGroup->calcList;
|
||||
|
||||
if(empty($dataSource))
|
||||
{
|
||||
$calc = current($calcList);
|
||||
$calc->setDAO($this->dao);
|
||||
$calc->setDAO($dao);
|
||||
|
||||
return $calc->getStatement();
|
||||
}
|
||||
|
||||
$dataset = $this->metric->getDataset($this->dao);
|
||||
$dataset = $this->metric->getDataset($dao);
|
||||
$fieldList = $this->metric->uniteFieldList($calcList);
|
||||
|
||||
return $dataset->$dataSource($fieldList);
|
||||
@@ -174,44 +176,135 @@ class metricZen extends metric
|
||||
* Build measurements that can be inserted into tables based on the results of the measurements computed.
|
||||
*
|
||||
* @param array $calcList
|
||||
* @param bool $isFirstGenerate
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareMetricRecord($calcList, $isFirstGenerate = false)
|
||||
protected function prepareMetricRecord($calcList)
|
||||
{
|
||||
$options = $isFirstGenerate ? array() : array('year' => date('Y'), 'month' => date('n'), 'week' => date('W'), 'day' => date('j'));
|
||||
$options = array('year' => date('Y'), 'month' => date('n'), 'week' => substr(date('oW'), -2), 'day' => date('j'));
|
||||
|
||||
$now = helper::now();
|
||||
$dateValues = $this->metric->generateDateValues($now);
|
||||
|
||||
$now = helper::now();
|
||||
$records = array();
|
||||
foreach($calcList as $code => $calc)
|
||||
{
|
||||
$metric = $this->metric->getByCode($code);
|
||||
$dateType = $this->metric->getDateTypeByCode($code);
|
||||
$recordCommon = $this->buildMetricRecordCommonFields($metric->id, $code, $now, $dateValues->$dateType);
|
||||
$initRecords = $this->initMetricRecords($recordCommon, $metric->scope);
|
||||
|
||||
$results = $calc->getResult($options);
|
||||
if(!is_array($results) || count($results) == 0) continue;
|
||||
|
||||
$system = (int)$this->metric->isSystemMetric($results);
|
||||
|
||||
$firstRecord = (object)current($results);
|
||||
$cycle = $this->metric->getMetricCycle($firstRecord);
|
||||
$this->metric->clearOutDatedRecords($code, $cycle);
|
||||
|
||||
foreach($results as $record)
|
||||
{
|
||||
$record = (object)$record;
|
||||
if(empty($record->value)) continue;
|
||||
|
||||
if(empty($record->value)) $record->value = 0;
|
||||
$record->metricID = $calc->id;
|
||||
$record->metricCode = $code;
|
||||
$record->date = $now;
|
||||
$record->system = $system;
|
||||
$record->system = $metric->scope == 'system' ? 1 : 0;
|
||||
|
||||
$records[] = $record;
|
||||
$uniqueKey = $this->getUniqueKeyByRecord($record);
|
||||
if(!isset($initRecords[$uniqueKey]))
|
||||
{
|
||||
$initRecords[$uniqueKey] = $record;
|
||||
continue;
|
||||
}
|
||||
|
||||
$initRecords[$uniqueKey]->value = $record->value;
|
||||
}
|
||||
|
||||
$records[$code] = array_values($initRecords);
|
||||
}
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据度量项编码,初始化度量数据。
|
||||
* Initialize metric data based on metric code.
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $dateType
|
||||
* @param string $date
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function initMetricRecords($recordCommon, $scope)
|
||||
{
|
||||
$records = array();
|
||||
if($scope == 'system')
|
||||
{
|
||||
$record = clone $recordCommon;
|
||||
$record->system = 1;
|
||||
$uniqueKey = $this->getUniqueKeyByRecord($record);
|
||||
|
||||
$records[$uniqueKey] = $record;
|
||||
}
|
||||
else
|
||||
{
|
||||
$scopeList = $this->metric->getPairsByScope($scope);
|
||||
foreach($scopeList as $key => $value)
|
||||
{
|
||||
$record = clone $recordCommon;
|
||||
$record->$scope = $key;
|
||||
$uniqueKey = $this->getUniqueKeyByRecord($record);
|
||||
|
||||
$records[$uniqueKey] = $record;
|
||||
}
|
||||
}
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据度量项范围,构建度量数据的通用字段。
|
||||
* Build common fields of metric data based on metric scope.
|
||||
*
|
||||
* @param int $metricID
|
||||
* @param string $code
|
||||
* @param string $scope
|
||||
* @param string $scopeValue
|
||||
* @param string $date
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function buildMetricRecordCommonFields($metricID, $code, $date, $dateValues)
|
||||
{
|
||||
$record = new stdclass();
|
||||
$record->value = 0;
|
||||
$record->metricID = $metricID;
|
||||
$record->metricCode = $code;
|
||||
$record->date = $date;
|
||||
|
||||
$record = (object)array_merge((array)$record, $dateValues);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据度量数据,获取度量数据的唯一键。
|
||||
* Get the unique key of metric data based on metric data.
|
||||
*
|
||||
* @param object $record
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function getUniqueKeyByRecord($record)
|
||||
{
|
||||
$record = (array)$record;
|
||||
$uniqueKeys = array();
|
||||
$ignoreFields = array('value', 'metricID', 'metricCode', 'date');
|
||||
foreach($record as $field => $value)
|
||||
{
|
||||
if(in_array($field, $ignoreFields) || empty($value)) continue;
|
||||
$uniqueKeys[] = $field . $value;
|
||||
}
|
||||
|
||||
return implode('_', $uniqueKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历数据,对每个度量项计算每一行数据。
|
||||
* Calculate metric for every row.
|
||||
@@ -396,7 +489,7 @@ class metricZen extends metric
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function getPagerExtra($tableWidth)
|
||||
public function getPagerExtra($tableWidth)
|
||||
{
|
||||
return ($tableWidth > 300) ? '' : 'shortPageSize';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user