optimize mail content limit max lines(100) of compare result
Signed-off-by: Lu Weitao luweitaobe@163.com --- lib/mail_job_result.rb | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/lib/mail_job_result.rb b/lib/mail_job_result.rb index 744b7d5c..0bf52b6e 100644 --- a/lib/mail_job_result.rb +++ b/lib/mail_job_result.rb @@ -24,10 +24,10 @@ class MailJobResult
def compose_mail set_submitter_info - context = get_compare_result(@job) + context = keep_100_lines(get_compare_result(@job)) return nil unless context
- subject = "[Compass-CI] job: #{@job_id} compare result" + subject = "[Compass-CI] commit: #{@job['upstream_commit']} comparsion result" signature = "Regards\nCompass-CI\nhttps://gitee.com/openeuler/compass-ci"
data = <<~BODY @@ -38,10 +38,15 @@ class MailJobResult Hi,
Thanks for your participation in Kunpeng and software ecosystem! - Your Job: #{@job_id} had finished. - Bellow are comparsion result of the base_commit and current_commit: - \tbase_commit: #{@job['base_commit']} - \tcurrent_commit: #{@job['upstream_commit']} + Bellow are comparsion result of the base commit and your commit: + \tbase commit: #{@job['base_commit']} + \tcommit_link: #{@job['upstream_url']}/commit/#{@job['base_commit']} + + \tyour commit: #{@job['upstream_commit']} + \tbranch: #{@job['upstream_branch']} + \tcommit_link: #{@job['upstream_url']}/commit/#{@job['upstream_commit']} + + compare upstream_commit=#{@job['base_commit']} upstream_commit=#{@job['upstream_commit']} --min_samples #{@job['nr_run']} #{context.to_s} \n\n#{signature}" BODY @@ -86,3 +91,15 @@ def get_compare_result(job) m_titles = [base_commit.slice(0, 16), commit_id.slice(0, 24)] compare_matrixes(matrices_list, suite_list, nil, m_titles, options: options) end + +def keep_100_lines(context) + num = 0 + new_context = '' + context.each_line do |line| + new_context += line + num += 1 + break if num > 99 + end + + new_context +end
On Thu, Apr 29, 2021 at 09:39:22PM +0800, Lu Weitao wrote:
please ignore
--------- Thanks, Lu Weitao
Hi, Thanks for your participation in Kunpeng and software ecosystem!
- Your Job: #{@job_id} had finished.
- Bellow are comparsion result of the base_commit and current_commit:
- \tbase_commit: #{@job['base_commit']}
- \tcurrent_commit: #{@job['upstream_commit']}
- Bellow are comparsion result of the base commit and your commit:
- \tbase commit: #{@job['base_commit']}
- \tcommit_link: #{@job['upstream_url']}/commit/#{@job['base_commit']}
- \tyour commit: #{@job['upstream_commit']}
- \tbranch: #{@job['upstream_branch']}
- \tcommit_link: #{@job['upstream_url']}/commit/#{@job['upstream_commit']}
- compare upstream_commit=#{@job['base_commit']} upstream_commit=#{@job['upstream_commit']} --min_samples #{@job['nr_run']} #{context.to_s} \n\n#{signature}" BODY
@@ -86,3 +91,15 @@ def get_compare_result(job) m_titles = [base_commit.slice(0, 16), commit_id.slice(0, 24)] compare_matrixes(matrices_list, suite_list, nil, m_titles, options: options) end
+def keep_100_lines(context)
- num = 0
- new_context = ''
- context.each_line do |line|
- new_context += line
- num += 1
- break if num > 99
- end
you do not need to handle it line by line, you can get the first 100 lines with: context.split("\n")[0,100].join("\n")
Thanks, Luan Shengde
- new_context
+end
2.23.0
+def keep_100_lines(context)
- num = 0
- new_context = ''
- context.each_line do |line|
- new_context += line
- num += 1
- break if num > 99
- end
you do not need to handle it line by line, you can get the first 100 lines with: context.split("\n")[0,100].join("\n")
ok tried, seem it's doesn't not work let's me try it once more
--------- Thanks, Lu Weitao
Thanks, Luan Shengde
- new_context
+end
2.23.0