-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-1086: dedupe & group delete results
WIP: Integrated into output email, not yet tested on real data.
- Loading branch information
Showing
4 changed files
with
68 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,22 @@ | |
# send notifications to users about recent deletes | ||
|
||
require 'net/smtp' | ||
require 'dedupe_delete_log' | ||
|
||
deletes = ARGF.readlines.map { |l| l.strip.split("\t") } | ||
def main | ||
dataset_emails = [ | ||
['ht_text_pd','dataset-pd','pd'], | ||
['ht_text_pd_open_access','dataset-pd-oa','pd_open'], | ||
['ht_text_pd_world','dataset-pd-world','pd_world'], | ||
['ht_text_pd_world_open_access','dataset-pd-world-oa','pd_world_open'] | ||
] | ||
|
||
deletes = DedupeDeleteLog.new(ARGV).compile_results | ||
|
||
dataset_emails.each do |subset_full_name,email,subset_short_name| | ||
email(subset_full_name,"#{email}@hathitrust.org",deletes[subset_short_name]) | ||
end | ||
end | ||
|
||
def email(set_name,recipient,data) | ||
(data.count < 1) and return | ||
|
@@ -32,23 +46,24 @@ def email(set_name,recipient,data) | |
===BEGIN ID LIST=== | ||
DOC | ||
data.each do |item| | ||
message+="#{item[1]}\n" | ||
message+="#{item}\n" | ||
end | ||
message+="===END ID LIST===\n" | ||
|
||
puts "sending message with #{data.count} deletes to #{recipient}" | ||
Net::SMTP.start(ENV['SMTP_HOST'] || 'localhost') do |smtp| | ||
smtp.send_message message, '[email protected]', recipient | ||
end | ||
send_or_preview(message,recipient) | ||
end | ||
|
||
dataset_emails = [ | ||
['ht_text_pd','dataset-pd','pd'], | ||
['ht_text_pd_open_access','dataset-pd-oa','pd_open'], | ||
['ht_text_pd_world','dataset-pd-world','pd_world'], | ||
['ht_text_pd_world_open_access','dataset-pd-world-oa','pd_world_open'] | ||
] | ||
|
||
dataset_emails.each do |subset_full_name,email,subset_short_name| | ||
email(subset_full_name,"#{email}@hathitrust.org",deletes.select { |i| i[0] == subset_short_name }.sort) | ||
def send_or_preview(message,recipient) | ||
if ENV['PREVIEW_EMAIL'] | ||
puts "To: [email protected], #{recipient}" | ||
puts | ||
puts message | ||
else | ||
Net::SMTP.start(ENV['SMTP_HOST'] || 'localhost') do |smtp| | ||
smtp.send_message message, '[email protected]', recipient | ||
end | ||
end | ||
end | ||
|
||
main if __FILE__ == $0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters