change to remove /-(\d+)$/
Exmaple: "taishan-xxx--xxx-12" remove "-12"
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com --- src/lib/web_backend.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index 4544690..419ef86 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -41,16 +41,19 @@ def es_count(query) ES_CLIENT.count(index: 'jobs*', body: query)['count'] end
-# "vm-hi1620-2p8g-212" remove "-212" -# "vm-hi1620-2p8g-zzz" remove "-zzz" -# "vm-git-bisect" don't remove "-bisect" +# vm-hi1620-2p4g-12 remove -12 +# taishan-xxx--xxx-12 remove -12 +# vm-hi1620-2p4g--0x remove --0x +# vm-hi1620-2p4g-abc remove -abc +# vm-git-bisect don't remove -bisect 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] + remove_index = r =~ /-(\d+)$/ + if r[0, 3] == 'vm-' + remove_index = r =~ /(--.+$)|(-\d\w*-[a-zA-Z]+$)/ || remove_index end + r = r[0, remove_index] if remove_index result.add r end result.to_a @@ -95,7 +98,7 @@ def compare_candidates_body OS: [ { os: 'openeuler', os_version: ['1.0', '20.03'] }, { os: 'centos', os_version: ['7.6', '7.8', '8.1', 'sid'] }, - { os: 'debian', os_version: ['10', 'sid'] }, + { os: 'debian', os_version: %w[10 sid] }, { os: 'archlinux', os_version: ['5.5.0-1'] } ], os_arch: %w[aarch64 x86_64],
Let's concentrate all the tbox_group manipulation logics into a central lib.
On Mon, Sep 28, 2020 at 03:49:19PM +0800, Zhang Yuhang wrote:
change to remove /-(\d+)$/
Exmaple: "taishan-xxx--xxx-12" remove "-12"
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com
src/lib/web_backend.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index 4544690..419ef86 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -41,16 +41,19 @@ def es_count(query) ES_CLIENT.count(index: 'jobs*', body: query)['count'] end
These comments are essential, however not enough. What's the reason or purpose for all these rules?
-# "vm-hi1620-2p8g-212" remove "-212" -# "vm-hi1620-2p8g-zzz" remove "-zzz" -# "vm-git-bisect" don't remove "-bisect" +# vm-hi1620-2p4g-12 remove -12 +# taishan-xxx--xxx-12 remove -12 +# vm-hi1620-2p4g--0x remove --0x +# vm-hi1620-2p4g-abc remove -abc +# vm-git-bisect don't remove -bisect
Thanks, Fengguang
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]
- remove_index = r =~ /-(\d+)$/
- if r[0, 3] == 'vm-'
endremove_index = r =~ /(--.+$)|(-\d\w*-[a-zA-Z]+$)/ || remove_index
- r = r[0, remove_index] if remove_index result.add r end result.to_a
@@ -95,7 +98,7 @@ def compare_candidates_body OS: [ { os: 'openeuler', os_version: ['1.0', '20.03'] }, { os: 'centos', os_version: ['7.6', '7.8', '8.1', 'sid'] },
{ os: 'debian', os_version: ['10', 'sid'] },
{ os: 'debian', os_version: %w[10 sid] }, { os: 'archlinux', os_version: ['5.5.0-1'] } ], os_arch: %w[aarch64 x86_64],
-- 2.23.0
On Mon, Sep 28, 2020 at 07:40:10PM +0800, Wu Fengguang wrote:
Let's concentrate all the tbox_group manipulation logics into a central lib.
On Mon, Sep 28, 2020 at 03:49:19PM +0800, Zhang Yuhang wrote:
change to remove /-(\d+)$/
Exmaple: "taishan-xxx--xxx-12" remove "-12"
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com
src/lib/web_backend.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index 4544690..419ef86 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -41,16 +41,19 @@ def es_count(query) ES_CLIENT.count(index: 'jobs*', body: query)['count'] end
These comments are essential, however not enough. What's the reason or purpose for all these rules?
-# "vm-hi1620-2p8g-212" remove "-212" -# "vm-hi1620-2p8g-zzz" remove "-zzz" -# "vm-git-bisect" don't remove "-bisect" +# vm-hi1620-2p4g-12 remove -12 +# taishan-xxx--xxx-12 remove -12 +# vm-hi1620-2p4g--0x remove --0x +# vm-hi1620-2p4g-abc remove -abc +# vm-git-bisect don't remove -bisect
Thanks, Fengguang
# string =~ regex # # 1. "-(\d+)$" # - description: if string last "-" char end with pure number, remove "-numbers" # - example: "xxx-xxx--xxx-12" remove "-12" # # 2. "--.+$" # - description: if string include "--" chars, remove "--chars" # - exmaple: "xxx-xxx--xxx" remove "--xxx" # # 3. "-\d\w*-[a-zA-Z]+$" # - description: if the word before string last "-" char start with a number and # the word after that "-" char is pure letter, remove "-letters" # - example: "xxx-2xx-abc" remove "-abc", "xxx-axx-abc", don't remove "-abc"
Would it be all right?
Thanks, Zhang Yuhang