-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements #9
base: master
Are you sure you want to change the base?
Improvements #9
Changes from 1 commit
8274bc3
17a3ea0
726d61a
c45e1e1
9f7bc88
dfbcc78
d409122
077a104
2ee35b3
9b83de9
ed5c9cb
e901b71
f4dbfe8
e3a0763
56c8b07
e64afd9
0596516
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,17 +11,28 @@ def initialize() | |
|
||
def start! | ||
birthdays = BirthdayReader.get_birthdays(@config.db_path) | ||
today = Time.now | ||
|
||
puts "Checking who was born today (#{today.to_s})" | ||
birthdays.each do |b| | ||
if (b[3].to_i == today.month) && (b[4].to_i == today.day) | ||
message = "#{@config.greeting_message} #{b[0]} #{b[1]}" | ||
HTTParty.post(@config.slack_url, body: { channel: @config.channel_name, | ||
username: @config.bot_name, | ||
text: message, | ||
icon_emoji: @config.bot_emoji }.to_json) | ||
puts "Checking who was born today" | ||
unless birthdays.nil? | ||
users = "<@#{ birthdays[0] }>" | ||
if birthdays.count > 1 | ||
puts "#{ birthdays.count } people were born today" | ||
if birthdays.count == 2 | ||
users = " <@#{ birthdays[0] }> and <@#{ birthdays[1] }> " | ||
else | ||
for i in 1..birthdays.count-2 | ||
users += ", <@#{ birthdays[i] }>" | ||
end | ||
users += " and <@#{ birthdays[i+1] }> " | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can simplify this:
What do you think ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shinenelson Did you take a look at this ? (mentions are missing here) |
||
message = "#{users} #{@config.greeting_message}" | ||
HTTParty.post(@config.slack_url, body: { channel: @config.channel_name, | ||
username: @config.bot_name, | ||
text: message, | ||
icon_emoji: @config.bot_emoji }.to_json) | ||
else | ||
puts "Today is a day that no one was born" | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you looked at my previous comment with a suggestion to refactor this function ?
|
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep
Time.now
in the logThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you wanted it in the log. The way I handle my
cron
s are, I prependdate
before my executing command. But I don't know if this works with Heroku's scheduler (does it?). Else I'll just put the date back in the log.