Add a weekly Newsletter for the latest open Bounties #19#36
Add a weekly Newsletter for the latest open Bounties #19#36clair13 wants to merge 14 commits intoexcid3:mainfrom
Conversation
|
Excellent work @clair13! Do you happen to have a screenshot of the email? |
|
I am pretty sure that my styling ideas will not be so good ,that's why I am saying to tell me exactly what you need.Also feel free to tell me any other things that need change. |
lib/tasks/bounty_tasks.rake
Outdated
| task send_bounty_email: :environment do | ||
| @bounties = Bounty.open.last(15) | ||
| if @bounties.any? | ||
| @users = User.all |
There was a problem hiding this comment.
Hi @clair13,
I feel this is performance intensive task (although it is rake task but still) as it will load the entire table into memory, instantiating all the rows; then iterate through the instances.
We can use find_each, as it does this in batches, which is more efficient in terms of memory usage.
something like below
User.find_each do |user|
BountyMailer.with(user: user, bounties: @bounties).open_bounty.deliver_later
endReferences
Retrieving Multiple Objects in Batches
ActiveRecord::Batches
There was a problem hiding this comment.
Thank you for the suggestion,I fixed it based on your suggestion.
|
I just wanted to follow up and see if there's anything else you need from me on this pull request. Please let me know. |

Hello, my name is George, I worked on issue #19 and added a weekly newsletter for the latest 15 open bounties.
I used the letter-opener gem and whenever gem for the scheduled emails to all registered users.
Now is scheduled the newsletter every Sunday at 17.00. You can change that on the following file
config/schedule.rb.Also by changing the number on the rake bounty task on the 3rd lineBounty.open.last(15), you can change the number of open Bounties.I added a mailer test and the test is passing all the assertions.
I would like to thank Chris @excid3 and everyone involved in this project.
Last but not least I would like to thank Cody @cnorm35 who opened this issue and helped me throughout the whole process answering all my questions and helping with issues I had along the way. It was a pleasure the whole process!!!