The parameter list for web compare need to change, as tbox_groups have $user at the back. Suite and tbox_group whose count < 2 need not to show, cause have no one to compare.
Signed-off-by: Li Yuanchao lyc163mail@163.com --- src/lib/web_backend.rb | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index da3c3c5..a9ab091 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -45,16 +45,11 @@ def es_count(query) ES_CLIENT.count(index: 'jobs*', body: query)['count'] end
-# "vm-2p8g--212" remove "--212" -# "vm-2p8g--zzz" remove "--zzz" -# "vm-git-bisect" don't remove "-bisect" +# delete $user after '--' or '.' or '~' def filter_tbox_group(es_result) result = Set.new es_result.each do |r| - if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-(([a-zA-Z]+)|(\d+))$)/ - index = r.index('--') || r.rindex('-') - r = r[0, index] - end + r = r.gsub(/(--|.|~).*$/, '') result.add r end result.to_a @@ -70,10 +65,10 @@ def all_suite size: 0 } es_result = es_query(query)['aggregations']['all_suite']['buckets'] - es_result.sort_by! { |h| h['doc_count'] } - es_result.reverse!.map! { |x| x['key'] } - - es_result + result_second = [] + es_result.each { |e| result_second << e if e['doc_count'] > 1 } + result_second.sort_by! { |h| h['doc_count'] } + result_second.reverse!.map! { |x| x['key'] } end
def all_tbox_group @@ -86,10 +81,12 @@ def all_tbox_group size: 0 } es_result = es_query(query)['aggregations']['all_tbox_group']['buckets'] - es_result.sort_by! { |h| h['doc_count'] } - es_result.reverse!.map! { |x| x['key'] } + result_second = [] + es_result.each { |e| result_second << e if e['doc_count'] > 1 } + result_second.sort_by! { |h| h['doc_count'] } + result_second.reverse!.map! { |x| x['key'] }
- filter_tbox_group(es_result) + filter_tbox_group(result_second) end
def compare_candidates_body
On Tue, Apr 27, 2021 at 08:39:59PM +0800, Li Yuanchao wrote:
The parameter list for web compare need to change, as tbox_groups have
tbox_group ---^
$user at the back. Suite and tbox_group whose count < 2 need not to show, cause have no one to compare.
Signed-off-by: Li Yuanchao lyc163mail@163.com
src/lib/web_backend.rb | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index da3c3c5..a9ab091 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -45,16 +45,11 @@ def es_count(query) ES_CLIENT.count(index: 'jobs*', body: query)['count'] end
-# "vm-2p8g--212" remove "--212" -# "vm-2p8g--zzz" remove "--zzz" -# "vm-git-bisect" don't remove "-bisect" +# delete $user after '--' or '.' or '~' def filter_tbox_group(es_result) result = Set.new es_result.each do |r|
- if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-(([a-zA-Z]+)|(\d+))$)/
index = r.index('--') || r.rindex('-')
r = r[0, index]
- end
- r = r.gsub(/(--|.|~).*$/, '') result.add r end result.to_a
@@ -70,10 +65,10 @@ def all_suite size: 0 } es_result = es_query(query)['aggregations']['all_suite']['buckets']
- es_result.sort_by! { |h| h['doc_count'] }
- es_result.reverse!.map! { |x| x['key'] }
- es_result
- result_second = []
- es_result.each { |e| result_second << e if e['doc_count'] > 1 }
- result_second.sort_by! { |h| h['doc_count'] }
- result_second.reverse!.map! { |x| x['key'] }
end
def all_tbox_group @@ -86,10 +81,12 @@ def all_tbox_group size: 0 } es_result = es_query(query)['aggregations']['all_tbox_group']['buckets']
- es_result.sort_by! { |h| h['doc_count'] }
- es_result.reverse!.map! { |x| x['key'] }
- result_second = []
- es_result.each { |e| result_second << e if e['doc_count'] > 1 }
- result_second.sort_by! { |h| h['doc_count'] }
- result_second.reverse!.map! { |x| x['key'] }
the above two parts of code are almost identical. you should reuse it.
Thanks, Ping
- filter_tbox_group(es_result)
- filter_tbox_group(result_second)
end
def compare_candidates_body
2.23.0