[why] Currently, the output result of compare default order by alphabet. If there have too many lines in result, it will be difficult for user to find the lines that starts with $suite in metric column.
[how] Divide the lines into two parts before print according to whether the line start with $suite or not, then combine output result into a whole to highlight the important info.
Signed-off-by: Lu Kaiyi 2392863668@qq.com --- lib/compare.rb | 15 +++++++++------ lib/compare_matrixes.rb | 35 ++++++++++++++++++++++++----------- lib/matrix2.rb | 12 ++++++++---- 3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/lib/compare.rb b/lib/compare.rb index 645f682..ebf35b1 100644 --- a/lib/compare.rb +++ b/lib/compare.rb @@ -20,8 +20,8 @@ require 'yaml'
def compare_matrices_list(argv, common_conditions, options) condition_list = parse_argv(argv, common_conditions) - matrices_list = create_matrices_list(condition_list) - compare_matrixes(matrices_list, options: options) + matrices_list, suites_list = create_matrices_list(condition_list) + compare_matrixes(matrices_list, suites_list, options: options) end
def parse_argv(argv, common_conditions) @@ -37,12 +37,15 @@ end
def create_matrices_list(conditions) matrices_list = [] + suites_list = [] es = ESQuery.new(ES_HOST, ES_PORT) conditions.each do |condition| query_results = es.multi_field_query(condition) - matrices_list << combine_query_data(query_results) + matrix, suite = combine_query_data(query_results) + matrices_list << matrix + suites_list.concat(suite) end - matrices_list + return matrices_list, suites_list end
# ------------------------------------------------------------------------------------------- @@ -58,8 +61,8 @@ end def compare_group(argv, dimensions, options) conditions = parse_conditions(argv) dims = dimensions.split(' ') - groups_matrices = create_groups_matrices_list(conditions, dims) - compare_group_matrices(groups_matrices, options) + groups_matrices, suites_list = create_groups_matrices_list(conditions, dims) + compare_group_matrices(groups_matrices, suites_list, options) end
def create_groups_matrices_list(conditions, dims) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index 119d42d..910f02f 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -193,7 +193,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end
-def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, options: {}) +def compare_matrixes(matrixes_list, suites_list, matrixes_titles = nil, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # @matrixes_list: list consisting of matrix # @matrixes_titles: number or dimension of matrix @@ -208,6 +208,7 @@ def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, opti result_str = group_key ? "\n\n\n\n\n" + group_key : '' result_str += get_all_result_str( matrixes_values, + suites_list, matrixes_titles, matrixes_list.size, options[:theme] @@ -382,7 +383,7 @@ end # compare each matrices_list within pre dimension of group matrices # input: group matrices # output: pre compare result of each group -def compare_group_matrices(group_matrices, options) +def compare_group_matrices(group_matrices, suites_list, options) result_str = '' group_matrices.each do |k, v| matrices_list = [] @@ -392,9 +393,9 @@ def compare_group_matrices(group_matrices, options) matrices_list << matrix end if options[:no_print] - result_str += compare_matrixes(matrices_list, matrices_titles, k, options: options) + result_str += compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options) else - print compare_matrixes(matrices_list, matrices_titles, k, options: options) + print compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options) end end result_str @@ -807,26 +808,38 @@ def get_theme(matrixes_values, matrixes_titles, theme) return THEMES[:none] end
-def get_all_result_str(matrixes_values, matrixes_titles, matrixes_number, theme) +def get_all_result_str(matrixes_values, suites_list, matrixes_titles, matrixes_number, theme) matrixes_titles ||= matrixes_number.times.to_a.map(&:to_s) theme = get_theme(matrixes_values, matrixes_titles, theme) return '' unless theme
- failure_str = get_result_str(matrixes_values[false].sort, matrixes_titles, false, theme) - success_str = get_result_str(matrixes_values[true].sort, matrixes_titles, true, theme) + failure_str = get_result_str(matrixes_values[false].sort, suites_list, matrixes_titles, false, theme) + success_str = get_result_str(matrixes_values[true].sort, suites_list, matrixes_titles, true, theme) failure_str + success_str end
-def get_result_str(values, matrixes_titles, success, theme) +def get_result_str(values, suites_list, matrixes_titles, success, theme) return '' if values.empty?
+ suites_list.uniq! result_str = "\n\n\n" common_title, compare_title = get_title_name(success) result_str += get_header(matrixes_titles, success, common_title, compare_title) + suite_str = '' + common_str = '' values.each do |field, matrixes| - result_str += get_values_str(matrixes, success, theme) - result_str += get_field_str(field) - result_str += "\n" + field_start_with_suite = suites_list.map { |suite| field.start_with?(suite) }.any? + if field_start_with_suite + suite_str += get_values_str(matrixes, success, theme) + suite_str += get_field_str(field) + suite_str += "\n" + else + common_str += get_values_str(matrixes, success, theme) + common_str += get_field_str(field) + common_str += "\n" + end end + + result_str += suite_str + common_str result_str end diff --git a/lib/matrix2.rb b/lib/matrix2.rb index 26f07fa..d6abf1b 100644 --- a/lib/matrix2.rb +++ b/lib/matrix2.rb @@ -76,7 +76,9 @@ end # } def create_matrix(job_list) matrix = {} + suite = [] job_list.each do |job| + suite << job['suite'] if job['suite'] stats = job['stats'] next unless stats
@@ -89,7 +91,7 @@ def create_matrix(job_list) matrix.each_value do |value| samples_fill_missing_zeros(value, col_size) end - matrix + return matrix, suite end
# input: query results from es_query @@ -110,15 +112,17 @@ end # ... # } def combine_group_query_data(query_data, dims) + suites_list = [] job_list = query_data['hits']['hits'] groups = auto_group(job_list, dims) groups.each do |group_key, value| value.each do |dimension_key, jobs| - groups[group_key][dimension_key] = create_matrix(jobs) + groups[group_key][dimension_key], suite = create_matrix(jobs) + suites_list.concat(suite) end groups.delete(group_key) if value.size < 2 end - groups + return groups, suites_list end
# input: @@ -139,7 +143,7 @@ def combine_group_jobs_list(query_data, groups_params, dimensions, metrics) groups = auto_group_by_template(job_list, groups_params, dimensions, metrics) groups.each do |group_key, dims| dims.each do |dim_key, jobs| - groups[group_key][dim_key] = create_matrix(jobs) + groups[group_key][dim_key], = create_matrix(jobs) end end
On Tue, Nov 10, 2020 at 03:55:24PM +0800, Lu Kaiyi wrote:
[why] Currently, the output result of compare default order by alphabet. If there have too many lines in result, it will be difficult for user to find the lines that starts with $suite in metric column.
[how] Divide the lines into two parts before print according to whether the line start with $suite or not, then combine output result into a whole to highlight the important info.
Signed-off-by: Lu Kaiyi 2392863668@qq.com
lib/compare.rb | 15 +++++++++------ lib/compare_matrixes.rb | 35 ++++++++++++++++++++++++----------- lib/matrix2.rb | 12 ++++++++---- 3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/lib/compare.rb b/lib/compare.rb index 645f682..ebf35b1 100644 --- a/lib/compare.rb +++ b/lib/compare.rb @@ -20,8 +20,8 @@ require 'yaml'
def compare_matrices_list(argv, common_conditions, options) condition_list = parse_argv(argv, common_conditions)
- matrices_list = create_matrices_list(condition_list)
- compare_matrixes(matrices_list, options: options)
- matrices_list, suites_list = create_matrices_list(condition_list)
- compare_matrixes(matrices_list, suites_list, options: options)
end
def parse_argv(argv, common_conditions) @@ -37,12 +37,15 @@ end
def create_matrices_list(conditions) matrices_list = []
- suites_list = [] es = ESQuery.new(ES_HOST, ES_PORT) conditions.each do |condition| query_results = es.multi_field_query(condition)
- matrices_list << combine_query_data(query_results)
- matrix, suite = combine_query_data(query_results)
- matrices_list << matrix
- suites_list.concat(suite) end
- matrices_list
- return matrices_list, suites_list
end
# ------------------------------------------------------------------------------------------- @@ -58,8 +61,8 @@ end def compare_group(argv, dimensions, options) conditions = parse_conditions(argv) dims = dimensions.split(' ')
- groups_matrices = create_groups_matrices_list(conditions, dims)
- compare_group_matrices(groups_matrices, options)
- groups_matrices, suites_list = create_groups_matrices_list(conditions, dims)
- compare_group_matrices(groups_matrices, suites_list, options)
end
def create_groups_matrices_list(conditions, dims) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index 119d42d..910f02f 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -193,7 +193,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end
-def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, options: {}) +def compare_matrixes(matrixes_list, suites_list, matrixes_titles = nil, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # @matrixes_list: list consisting of matrix # @matrixes_titles: number or dimension of matrix @@ -208,6 +208,7 @@ def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, opti result_str = group_key ? "\n\n\n\n\n" + group_key : '' result_str += get_all_result_str( matrixes_values,
- suites_list, matrixes_titles, matrixes_list.size, options[:theme]
@@ -382,7 +383,7 @@ end # compare each matrices_list within pre dimension of group matrices # input: group matrices # output: pre compare result of each group -def compare_group_matrices(group_matrices, options) +def compare_group_matrices(group_matrices, suites_list, options) result_str = '' group_matrices.each do |k, v| matrices_list = [] @@ -392,9 +393,9 @@ def compare_group_matrices(group_matrices, options) matrices_list << matrix end if options[:no_print]
result_str += compare_matrixes(matrices_list, matrices_titles, k, options: options)
elseresult_str += compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options)
print compare_matrixes(matrices_list, matrices_titles, k, options: options)
end end result_strprint compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options)
@@ -807,26 +808,38 @@ def get_theme(matrixes_values, matrixes_titles, theme) return THEMES[:none] end
-def get_all_result_str(matrixes_values, matrixes_titles, matrixes_number, theme) +def get_all_result_str(matrixes_values, suites_list, matrixes_titles, matrixes_number, theme) matrixes_titles ||= matrixes_number.times.to_a.map(&:to_s) theme = get_theme(matrixes_values, matrixes_titles, theme) return '' unless theme
- failure_str = get_result_str(matrixes_values[false].sort, matrixes_titles, false, theme)
- success_str = get_result_str(matrixes_values[true].sort, matrixes_titles, true, theme)
- failure_str = get_result_str(matrixes_values[false].sort, suites_list, matrixes_titles, false, theme)
- success_str = get_result_str(matrixes_values[true].sort, suites_list, matrixes_titles, true, theme) failure_str + success_str
end
-def get_result_str(values, matrixes_titles, success, theme) +def get_result_str(values, suites_list, matrixes_titles, success, theme) return '' if values.empty?
- suites_list.uniq! result_str = "\n\n\n" common_title, compare_title = get_title_name(success) result_str += get_header(matrixes_titles, success, common_title, compare_title)
- suite_str = ''
- common_str = '' values.each do |field, matrixes|
- result_str += get_values_str(matrixes, success, theme)
- result_str += get_field_str(field)
- result_str += "\n"
- field_start_with_suite = suites_list.map { |suite| field.start_with?(suite) }.any?
- if field_start_with_suite
suite_str += get_values_str(matrixes, success, theme)
suite_str += get_field_str(field)
suite_str += "\n"
- else
common_str += get_values_str(matrixes, success, theme)
common_str += get_field_str(field)
common_str += "\n"
- end
row = get_values_str(matrixes, success, theme) row += get_field_str(field) + "\n"
if suites_list.any?{ |suite| field.start_with?(suite) } suite_str += row else common_str += row end
Could we write like this?
Thanks, Zhang Yuhang
end
- result_str += suite_str + common_str result_str
end diff --git a/lib/matrix2.rb b/lib/matrix2.rb index 26f07fa..d6abf1b 100644 --- a/lib/matrix2.rb +++ b/lib/matrix2.rb @@ -76,7 +76,9 @@ end # } def create_matrix(job_list) matrix = {}
- suite = [] job_list.each do |job|
- suite << job['suite'] if job['suite'] stats = job['stats'] next unless stats
@@ -89,7 +91,7 @@ def create_matrix(job_list) matrix.each_value do |value| samples_fill_missing_zeros(value, col_size) end
- matrix
- return matrix, suite
end
# input: query results from es_query @@ -110,15 +112,17 @@ end # ... # } def combine_group_query_data(query_data, dims)
- suites_list = [] job_list = query_data['hits']['hits'] groups = auto_group(job_list, dims) groups.each do |group_key, value| value.each do |dimension_key, jobs|
groups[group_key][dimension_key] = create_matrix(jobs)
groups[group_key][dimension_key], suite = create_matrix(jobs)
end groups.delete(group_key) if value.size < 2 endsuites_list.concat(suite)
- groups
- return groups, suites_list
end
# input: @@ -139,7 +143,7 @@ def combine_group_jobs_list(query_data, groups_params, dimensions, metrics) groups = auto_group_by_template(job_list, groups_params, dimensions, metrics) groups.each do |group_key, dims| dims.each do |dim_key, jobs|
groups[group_key][dim_key] = create_matrix(jobs)
end endgroups[group_key][dim_key], = create_matrix(jobs)
-- 2.23.0
On Tue, Nov 10, 2020 at 04:42:18PM +0800, Zhang Yuhang wrote:
On Tue, Nov 10, 2020 at 03:55:24PM +0800, Lu Kaiyi wrote:
[why] Currently, the output result of compare default order by alphabet. If there have too many lines in result, it will be difficult for user to find the lines that starts with $suite in metric column.
[how] Divide the lines into two parts before print according to whether the line start with $suite or not, then combine output result into a whole to highlight the important info.
Signed-off-by: Lu Kaiyi 2392863668@qq.com
lib/compare.rb | 15 +++++++++------ lib/compare_matrixes.rb | 35 ++++++++++++++++++++++++----------- lib/matrix2.rb | 12 ++++++++---- 3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/lib/compare.rb b/lib/compare.rb index 645f682..ebf35b1 100644 --- a/lib/compare.rb +++ b/lib/compare.rb @@ -20,8 +20,8 @@ require 'yaml'
def compare_matrices_list(argv, common_conditions, options) condition_list = parse_argv(argv, common_conditions)
- matrices_list = create_matrices_list(condition_list)
- compare_matrixes(matrices_list, options: options)
- matrices_list, suites_list = create_matrices_list(condition_list)
- compare_matrixes(matrices_list, suites_list, options: options)
end
def parse_argv(argv, common_conditions) @@ -37,12 +37,15 @@ end
def create_matrices_list(conditions) matrices_list = []
- suites_list = [] es = ESQuery.new(ES_HOST, ES_PORT) conditions.each do |condition| query_results = es.multi_field_query(condition)
- matrices_list << combine_query_data(query_results)
- matrix, suite = combine_query_data(query_results)
- matrices_list << matrix
- suites_list.concat(suite) end
- matrices_list
- return matrices_list, suites_list
end
# ------------------------------------------------------------------------------------------- @@ -58,8 +61,8 @@ end def compare_group(argv, dimensions, options) conditions = parse_conditions(argv) dims = dimensions.split(' ')
- groups_matrices = create_groups_matrices_list(conditions, dims)
- compare_group_matrices(groups_matrices, options)
- groups_matrices, suites_list = create_groups_matrices_list(conditions, dims)
- compare_group_matrices(groups_matrices, suites_list, options)
end
def create_groups_matrices_list(conditions, dims) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index 119d42d..910f02f 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -193,7 +193,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end
-def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, options: {}) +def compare_matrixes(matrixes_list, suites_list, matrixes_titles = nil, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # @matrixes_list: list consisting of matrix # @matrixes_titles: number or dimension of matrix @@ -208,6 +208,7 @@ def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, opti result_str = group_key ? "\n\n\n\n\n" + group_key : '' result_str += get_all_result_str( matrixes_values,
- suites_list, matrixes_titles, matrixes_list.size, options[:theme]
@@ -382,7 +383,7 @@ end # compare each matrices_list within pre dimension of group matrices # input: group matrices # output: pre compare result of each group -def compare_group_matrices(group_matrices, options) +def compare_group_matrices(group_matrices, suites_list, options) result_str = '' group_matrices.each do |k, v| matrices_list = [] @@ -392,9 +393,9 @@ def compare_group_matrices(group_matrices, options) matrices_list << matrix end if options[:no_print]
result_str += compare_matrixes(matrices_list, matrices_titles, k, options: options)
elseresult_str += compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options)
print compare_matrixes(matrices_list, matrices_titles, k, options: options)
end end result_strprint compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options)
@@ -807,26 +808,38 @@ def get_theme(matrixes_values, matrixes_titles, theme) return THEMES[:none] end
-def get_all_result_str(matrixes_values, matrixes_titles, matrixes_number, theme) +def get_all_result_str(matrixes_values, suites_list, matrixes_titles, matrixes_number, theme) matrixes_titles ||= matrixes_number.times.to_a.map(&:to_s) theme = get_theme(matrixes_values, matrixes_titles, theme) return '' unless theme
- failure_str = get_result_str(matrixes_values[false].sort, matrixes_titles, false, theme)
- success_str = get_result_str(matrixes_values[true].sort, matrixes_titles, true, theme)
- failure_str = get_result_str(matrixes_values[false].sort, suites_list, matrixes_titles, false, theme)
- success_str = get_result_str(matrixes_values[true].sort, suites_list, matrixes_titles, true, theme) failure_str + success_str
end
-def get_result_str(values, matrixes_titles, success, theme) +def get_result_str(values, suites_list, matrixes_titles, success, theme) return '' if values.empty?
- suites_list.uniq! result_str = "\n\n\n" common_title, compare_title = get_title_name(success) result_str += get_header(matrixes_titles, success, common_title, compare_title)
- suite_str = ''
- common_str = '' values.each do |field, matrixes|
- result_str += get_values_str(matrixes, success, theme)
- result_str += get_field_str(field)
- result_str += "\n"
- field_start_with_suite = suites_list.map { |suite| field.start_with?(suite) }.any?
- if field_start_with_suite
suite_str += get_values_str(matrixes, success, theme)
suite_str += get_field_str(field)
suite_str += "\n"
- else
common_str += get_values_str(matrixes, success, theme)
common_str += get_field_str(field)
common_str += "\n"
- end
row = get_values_str(matrixes, success, theme) row += get_field_str(field) + "\n"
if suites_list.any?{ |suite| field.start_with?(suite) } suite_str += row else common_str += row end
Could we write like this?
Thanks, Zhang Yuhang
awesome, it's a good idea to remove redundant code line!
Thanks, Kaiyi
end
- result_str += suite_str + common_str result_str
end diff --git a/lib/matrix2.rb b/lib/matrix2.rb index 26f07fa..d6abf1b 100644 --- a/lib/matrix2.rb +++ b/lib/matrix2.rb @@ -76,7 +76,9 @@ end # } def create_matrix(job_list) matrix = {}
- suite = [] job_list.each do |job|
- suite << job['suite'] if job['suite'] stats = job['stats'] next unless stats
@@ -89,7 +91,7 @@ def create_matrix(job_list) matrix.each_value do |value| samples_fill_missing_zeros(value, col_size) end
- matrix
- return matrix, suite
end
# input: query results from es_query @@ -110,15 +112,17 @@ end # ... # } def combine_group_query_data(query_data, dims)
- suites_list = [] job_list = query_data['hits']['hits'] groups = auto_group(job_list, dims) groups.each do |group_key, value| value.each do |dimension_key, jobs|
groups[group_key][dimension_key] = create_matrix(jobs)
groups[group_key][dimension_key], suite = create_matrix(jobs)
end groups.delete(group_key) if value.size < 2 endsuites_list.concat(suite)
- groups
- return groups, suites_list
end
# input: @@ -139,7 +143,7 @@ def combine_group_jobs_list(query_data, groups_params, dimensions, metrics) groups = auto_group_by_template(job_list, groups_params, dimensions, metrics) groups.each do |group_key, dims| dims.each do |dim_key, jobs|
groups[group_key][dim_key] = create_matrix(jobs)
end endgroups[group_key][dim_key], = create_matrix(jobs)
-- 2.23.0
On Tue, Nov 10, 2020 at 03:55:24PM +0800, Lu Kaiyi wrote:
[why] Currently, the output result of compare default order by alphabet. If there have too many lines in result, it will be difficult for user to find the lines that starts with $suite in metric column.
[how] Divide the lines into two parts before print according to whether the line start with $suite or not, then combine output result into a whole to highlight the important info.
we'd better give an example in change log
Signed-off-by: Lu Kaiyi 2392863668@qq.com
lib/compare.rb | 15 +++++++++------ lib/compare_matrixes.rb | 35 ++++++++++++++++++++++++----------- lib/matrix2.rb | 12 ++++++++---- 3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/lib/compare.rb b/lib/compare.rb index 645f682..ebf35b1 100644 --- a/lib/compare.rb +++ b/lib/compare.rb @@ -20,8 +20,8 @@ require 'yaml'
def compare_matrices_list(argv, common_conditions, options) condition_list = parse_argv(argv, common_conditions)
- matrices_list = create_matrices_list(condition_list)
- compare_matrixes(matrices_list, options: options)
- matrices_list, suites_list = create_matrices_list(condition_list)
- compare_matrixes(matrices_list, suites_list, options: options)
end
def parse_argv(argv, common_conditions) @@ -37,12 +37,15 @@ end
def create_matrices_list(conditions) matrices_list = []
- suites_list = [] es = ESQuery.new(ES_HOST, ES_PORT) conditions.each do |condition| query_results = es.multi_field_query(condition)
- matrices_list << combine_query_data(query_results)
- matrix, suite = combine_query_data(query_results)
- matrices_list << matrix
- suites_list.concat(suite) end
- matrices_list
- return matrices_list, suites_list
end
# ------------------------------------------------------------------------------------------- @@ -58,8 +61,8 @@ end def compare_group(argv, dimensions, options) conditions = parse_conditions(argv) dims = dimensions.split(' ')
- groups_matrices = create_groups_matrices_list(conditions, dims)
- compare_group_matrices(groups_matrices, options)
- groups_matrices, suites_list = create_groups_matrices_list(conditions, dims)
- compare_group_matrices(groups_matrices, suites_list, options)
end
def create_groups_matrices_list(conditions, dims) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index 119d42d..910f02f 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -193,7 +193,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end
-def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, options: {}) +def compare_matrixes(matrixes_list, suites_list, matrixes_titles = nil, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # @matrixes_list: list consisting of matrix # @matrixes_titles: number or dimension of matrix @@ -208,6 +208,7 @@ def compare_matrixes(matrixes_list, matrixes_titles = nil, group_key = nil, opti result_str = group_key ? "\n\n\n\n\n" + group_key : '' result_str += get_all_result_str( matrixes_values,
- suites_list, matrixes_titles, matrixes_list.size, options[:theme]
@@ -382,7 +383,7 @@ end # compare each matrices_list within pre dimension of group matrices # input: group matrices # output: pre compare result of each group -def compare_group_matrices(group_matrices, options) +def compare_group_matrices(group_matrices, suites_list, options) result_str = '' group_matrices.each do |k, v| matrices_list = [] @@ -392,9 +393,9 @@ def compare_group_matrices(group_matrices, options) matrices_list << matrix end if options[:no_print]
result_str += compare_matrixes(matrices_list, matrices_titles, k, options: options)
elseresult_str += compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options)
print compare_matrixes(matrices_list, matrices_titles, k, options: options)
end end result_strprint compare_matrixes(matrices_list, suites_list, matrices_titles, k, options: options)
@@ -807,26 +808,38 @@ def get_theme(matrixes_values, matrixes_titles, theme) return THEMES[:none] end
-def get_all_result_str(matrixes_values, matrixes_titles, matrixes_number, theme) +def get_all_result_str(matrixes_values, suites_list, matrixes_titles, matrixes_number, theme) matrixes_titles ||= matrixes_number.times.to_a.map(&:to_s) theme = get_theme(matrixes_values, matrixes_titles, theme) return '' unless theme
- failure_str = get_result_str(matrixes_values[false].sort, matrixes_titles, false, theme)
- success_str = get_result_str(matrixes_values[true].sort, matrixes_titles, true, theme)
- failure_str = get_result_str(matrixes_values[false].sort, suites_list, matrixes_titles, false, theme)
- success_str = get_result_str(matrixes_values[true].sort, suites_list, matrixes_titles, true, theme) failure_str + success_str
end
-def get_result_str(values, matrixes_titles, success, theme) +def get_result_str(values, suites_list, matrixes_titles, success, theme) return '' if values.empty?
- suites_list.uniq! result_str = "\n\n\n" common_title, compare_title = get_title_name(success) result_str += get_header(matrixes_titles, success, common_title, compare_title)
- suite_str = ''
- common_str = '' values.each do |field, matrixes|
- result_str += get_values_str(matrixes, success, theme)
- result_str += get_field_str(field)
- result_str += "\n"
- field_start_with_suite = suites_list.map { |suite| field.start_with?(suite) }.any?
- if field_start_with_suite
suite_str += get_values_str(matrixes, success, theme)
suite_str += get_field_str(field)
suite_str += "\n"
- else
common_str += get_values_str(matrixes, success, theme)
common_str += get_field_str(field)
common_str += "\n"
- end
if ... else ...end this block can be defined a new function
end
- result_str += suite_str + common_str
this function more than 15 lines you can use rubocop check each file at first
result_str end diff --git a/lib/matrix2.rb b/lib/matrix2.rb index 26f07fa..d6abf1b 100644 --- a/lib/matrix2.rb +++ b/lib/matrix2.rb @@ -76,7 +76,9 @@ end # } def create_matrix(job_list) matrix = {}
- suite = []
suite => suites
job_list.each do |job|
- suite << job['suite'] if job['suite'] stats = job['stats'] next unless stats
@@ -89,7 +91,7 @@ def create_matrix(job_list) matrix.each_value do |value| samples_fill_missing_zeros(value, col_size) end
- matrix
- return matrix, suite
end
we had the function combine_query_data() miss deal with it? if user compare like: compare "id=xxx_11,xxx_12", "id=xxx_21, xxx_22"
# input: query results from es_query @@ -110,15 +112,17 @@ end # ... # } def combine_group_query_data(query_data, dims)
- suites_list = [] job_list = query_data['hits']['hits'] groups = auto_group(job_list, dims) groups.each do |group_key, value|
per group_key have matrices_list + suites_list
per matrix have suites which may like: ["iperf", "netperf"] mostly there is only one suite of a matrix
value.each do |dimension_key, jobs|
groups[group_key][dimension_key] = create_matrix(jobs)
groups[group_key][dimension_key], suite = create_matrix(jobs)
suites_list.concat(suite)
suites_list.concat(suite) => suite_list << suite
for exmplate: suite_1 = ['iperf', 'netperf'] suite_2 = ['iperf', 'fio-basic']
suites_list.concat(suite) the final result : ['iperf', 'netperf', 'iperf', 'fio-basic']
suite_list << suite the final result: [['iperf', 'netperf'], ['iperf', 'fio-basic']]
suite_list[0] will be the 1st matrix's title of mrtrices_list
end groups.delete(group_key) if value.size < 2
end
- groups
add empty line at here
Thanks, Weitao
- return groups, suites_list
end
# input: @@ -139,7 +143,7 @@ def combine_group_jobs_list(query_data, groups_params, dimensions, metrics) groups = auto_group_by_template(job_list, groups_params, dimensions, metrics) groups.each do |group_key, dims| dims.each do |dim_key, jobs|
groups[group_key][dim_key] = create_matrix(jobs)
end endgroups[group_key][dim_key], = create_matrix(jobs)
-- 2.23.0