On Tue, Nov 03, 2020 at 03:01:58PM +0800, Zhang Yuhang wrote:
On Tue, Nov 03, 2020 at 02:49:41PM +0800, Lu Weitao wrote:
+def get_group_by_template(job_list, group_params, dimensions, metrics)
- groups = {}
- job_list.each do |job|
- next unless job['stats']
- group_key = get_user_group_key(job, group_params)
- dimension = get_user_dimension(job, dimensions)
- next unless group_key && dimension
- new_job = get_new_job_by_metrics(job, metrics)
I did not find function name like "get_new_job_by_xxx", just "get_new_job_by_metrices".
If we will not create function like "get_new_job_by_xxx" in futuer, Maybe better that rename "get_new_job_by_metrics" to "get_new_job".
get_new_job is better, we have comments for the function
Thanks, Weitao
Thanks, Zhang Yuhang
+# @metrics Array(String) +# eg: +# ["fio.read_iops", "fio.write_iops"] +# return new_job +# eg: +# {'stats' => {'fio.write_iops' => 312821.002387, 'fio.read_iops' => 212821.2387}}, +def get_new_job_by_metrics(job, metrics)
- new_job = {}
- metrics.each do |metric|
- if job['stats'].key?(metric)
new_job['stats'] ||= {}
new_job['stats'][metric] = job['stats'][metric]
- end
- end
- new_job
+end
2.23.0