Commit 296aae7b authored by gm's avatar gm

修正循环获取上线日期,而没有及时break的问题

parent 4cef2763
...@@ -26,7 +26,7 @@ gem mail 提供了邮件能力。具体见send_email方法的实现 ...@@ -26,7 +26,7 @@ gem mail 提供了邮件能力。具体见send_email方法的实现
def login def login
# 登录 # 登录
options = { options = {
:body => {:os_username => "wangyang", :os_password => 'wind1988wind', :login => '%E7%99%BB%E5%BD%95' }, :body => {:os_username => " jaguar", :os_password => 'jaguar@GM123', :login => '%E7%99%BB%E5%BD%95' },
:headers => { :headers => {
'Content-Type' => 'application/x-www-form-urlencoded', 'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => 'application/json, text/javascript, */*; q=0.01' 'Accept' => 'application/json, text/javascript, */*; q=0.01'
...@@ -66,14 +66,14 @@ end ...@@ -66,14 +66,14 @@ end
# 类似于“7.11开发”这样的事件名,用于对比记录邮件是否已经发送 # 类似于“7.11开发”这样的事件名,用于对比记录邮件是否已经发送
$dev_title = "" $dev_title = ""
# 类似于“7.11客户端提交”这样的事件名,用于稍后发邮件 # 类似于“7.11客户端提交”这样的事件名,用于稍后发邮件
$title = "" $submit_title = ""
# 类似于“7.11客户端提交”这样的事件的时间,用于稍后发邮件 # 类似于“7.11客户端提交”这样的事件的时间,用于稍后发邮件
$date = "" $submit_date = ""
# 用来存储全局变量$dev_title的文件名 # 用来存储全局变量$dev_title的文件名
STORE_KEY = "sprintEmailHistory.log" STORE_KEY = "sprintEmailHistory.log"
# 返回值:Deliver # 返回值:Deliver
def get_deliver_info def get_submit_info
# 以后端上线时间为准,保证程序员不被其它工作量压到下一个迭代的开发周 # 以后端上线时间为准,保证程序员不被其它工作量压到下一个迭代的开发周
dev_event_id = "e1c8aef8-130e-40bf-8f6c-fe0e5c5dbd9c" # 提交时间 dev_event_id = "e1c8aef8-130e-40bf-8f6c-fe0e5c5dbd9c" # 提交时间
# backend_deploy_event_id = "8389fda3-a06c-49b5-af85-788c4af12071" # 后端上线时间 # backend_deploy_event_id = "8389fda3-a06c-49b5-af85-788c4af12071" # 后端上线时间
...@@ -84,8 +84,9 @@ def get_deliver_info ...@@ -84,8 +84,9 @@ def get_deliver_info
for event in obj.events for event in obj.events
deploy_date = Date.parse(event.start) deploy_date = Date.parse(event.start)
if deploy_date > today if deploy_date > today
$title = event.title $submit_title = event.title
$date = deploy_date $submit_date = deploy_date
break
end end
end end
end end
...@@ -114,7 +115,6 @@ def should_send_email_today ...@@ -114,7 +115,6 @@ def should_send_email_today
puts "history #{history}" puts "history #{history}"
for event in obj.events for event in obj.events
puts "#{event.title} #{event.start}"
start = Date.parse(event.start) start = Date.parse(event.start)
if start == today if start == today
...@@ -122,6 +122,7 @@ def should_send_email_today ...@@ -122,6 +122,7 @@ def should_send_email_today
puts "#{event.title} 版本已经发过邮件" puts "#{event.title} 版本已经发过邮件"
return false return false
else else
puts "dev_title #{$dev_title}, event_title #{event.title}"
$dev_title = event.title $dev_title = event.title
puts "可以发送邮件" puts "可以发送邮件"
return true return true
...@@ -149,28 +150,37 @@ def send_email() ...@@ -149,28 +150,37 @@ def send_email()
mail = Mail.deliver do mail = Mail.deliver do
# 其实下面都是方法调用,不要被迷惑了 # 其实下面都是方法调用,不要被迷惑了
to ['hualu@igengmei.com', 'wangjun@igengmei.com', 'sunwenhui@igengmei.com', 'zhucuicui@igengmei.com', 'huchunhe@igengmei.com', 'dongqiang@igengmei.com', 'SJ-liuxiao@igengmei.com', 'client-rd@igengmei.com'] to ['hualu@igengmei.com', 'wangjun@igengmei.com', 'sunwenhui@igengmei.com', 'zhucuicui@igengmei.com', 'huchunhe@igengmei.com', 'dongqiang@igengmei.com', 'SJ-liuxiao@igengmei.com', 'client-rd@igengmei.com', 'wanghongying@igengmei.com', 'liuxiaojie@igengmei.com']
# to ['jaguar@igengmei.com'] #to ['jaguar@igengmei.com']
bcc 'jaguar@igengmei.com' # 抄送 bcc 'jaguar@igengmei.com' # 抄送
from 'jaguar@igengmei.com' # 发件人 from 'jaguar@igengmei.com' # 发件人
subject "更美app#{$title}商店物料信息" subject "更美app#{$submit_title}商店物料信息"
text_part do text_part do
content_type "text/plain; charset=utf-8" content_type "text/plain; charset=utf-8"
body <<-EOF body <<-EOF
Hi,All Hi,All
#{$title}时间为#{$date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~ #{$submit_title}时间为#{$submit_date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
EOF EOF
end end
end end
end end
def test_email_body()
puts <<-EOF
Hi,All
#{$submit_title}时间为#{$submit_date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
EOF
end
login login
if should_send_email_today if should_send_email_today
get_deliver_info get_submit_info
begin begin
# test_email_body
# 邮件发送成功后,再存储数据 # 邮件发送成功后,再存储数据
send_email send_email
set_store_value(STORE_KEY, $dev_title) set_store_value(STORE_KEY, $dev_title)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment