refactor(manager): parallelize sent emails retrieval
This commit is contained in:
parent
dbb34d2b36
commit
366c95af7d
1 changed files with 10 additions and 7 deletions
|
@ -79,14 +79,17 @@ module Manager
|
||||||
email_services = [
|
email_services = [
|
||||||
Sendinblue::API.new,
|
Sendinblue::API.new,
|
||||||
Dolist::API.new
|
Dolist::API.new
|
||||||
]
|
].filter(&:properly_configured?)
|
||||||
|
|
||||||
@sent_mails = email_services
|
@sent_mails = Concurrent::Array.new
|
||||||
.filter(&:properly_configured?)
|
email_services.map do |api|
|
||||||
.map { |api| api.sent_mails(@user.email) }
|
Thread.new do
|
||||||
.flatten
|
mails = api.sent_mails(@user.email)
|
||||||
.sort_by(&:delivered_at)
|
@sent_mails.concat(mails)
|
||||||
.reverse
|
end
|
||||||
|
end.each(&:join)
|
||||||
|
|
||||||
|
@sent_mails.sort_by!(&:delivered_at).reverse!
|
||||||
end
|
end
|
||||||
|
|
||||||
def unblock_email
|
def unblock_email
|
||||||
|
|
Loading…
Reference in a new issue