Skip to content

Commit

Permalink
Merge branch 'master' into fc_1786_2_av
Browse files Browse the repository at this point in the history
  • Loading branch information
AnneV-Learn committed Jul 19, 2024
2 parents 8d7514f + 4d040c6 commit e4b2ed6
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 36 deletions.
4 changes: 2 additions & 2 deletions app/assets_freereg/styles/css/icons.data.svg.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def batch_processing_success(message, user, batch)
adjust_email_recipients(subject)
end

def communicate_github_issue_creation(feedback)
@feedback = feedback
@user = UseridDetail.where(userid: feedback.user_id).first
@user_email = @user.email_address
mail(to: @user_email, :subject => 'Notification of github issue creation')
end


def contact_action_request(contact, send_to, copies_to)
@appname = appname
@contact = contact
Expand Down Expand Up @@ -123,7 +131,7 @@ def coordinator_contact_reply(contact, ccs_userids, message, sender_userid)

def coordinator_feedback_reply(feedback, ccs_userids, message, sender_userid)
@appname = appname
@feedback = feedback
@feedback = feedbackappname
@message = message
@cc_email_addresses = get_email_address_array_from_array_of_userids(ccs_userids)
sender_email_address = get_email_address_from_userid(sender_userid)
Expand Down Expand Up @@ -522,9 +530,11 @@ def send_logs(file, ccs, body_message, subjects)
def send_upload_stats(start_date, end_date)
@start_date = start_date
@end_date = end_date
@uploaders_count, @email_confirmed, @users_count = PhysicalFile.new.upload_report_mail(@start_date, @end_date)
@uploaders_count, @email_confirmed, @users_count, @records_added = PhysicalFile.new.upload_report_mail(@start_date, @end_date)
@transcribers_count, @active_transcribers_count, @email_confimed = UseridDetail.get_transcriber_stats(@start_date, @end_date)
mail(from: "[email protected]", to: 'Denise Colbert <[email protected]>',cc: 'Vinodhini Subbu <[email protected]>', subject: "Upload report stats")
from_email = "no-reply@#{appname.downcase}.org.uk"
to_email, cc_email = app_specific_email_upload_stats
mail(from: from_email, to: to_email, cc: cc_email, subject: "Upload report stats")
end

def embargo_process_completion_email(rule_id, ccs)
Expand Down Expand Up @@ -569,6 +579,20 @@ def adjust_email_recipients(message)
end
end

def app_specific_email_upload_stats
to_email = ''
cc_email = ''
case appname.downcase
when 'freereg'
to_email = '[email protected]'
cc_email = "[email protected]"
when 'freecen'
to_email = '[email protected]'
cc_email = "[email protected]"
end
[to_email, cc_email]
end

def get_email_address_array_from_array_of_userids(userids)
array_of_email_addresses = []
if userids.present?
Expand Down
1 change: 1 addition & 0 deletions app/models/feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def github_issue
logger.info("#{appname}:GITHUB response: #{response}")
logger.info(response.inspect)
self.update_attributes(:github_issue_url => response[:html_url],:github_comment_url => response[:comments_url], :github_number => response[:number])
UserMailer.communicate_github_issue_creation(self).deliver_now
else
logger.error("#{appname}:Tried to create an issue, but Github integration is not enabled!")
end
Expand Down
47 changes: 47 additions & 0 deletions app/models/freecen_csv_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,53 @@ def validate_on_line_edit_of_fields(fields)
end

def translate_date
myage = age.to_i
census_year = year
adjustment = 0 # this is all we need to do for day and week age units
myage_unit_included = age[-1].match?(/[A-Za-z]/) if age.present?
if myage_unit_included
myage_unit = age[-1]
if myage_unit == 'y'
adjustment = 0 - myage
end
if myage_unit == 'm'
if census_year == RecordType::CENSUS_1841
# Census day: June 6, 1841
#
# Ages in the 1841 Census
# The census takers were instructed to give the exact ages of children
# but to round the ages of those older than 15 down to a lower multiple of 5.
# For example, a 59-year-old person would be listed as 55. Not all census
# enumerators followed these instructions. Some recorded the exact age;
# some even rounded the age up to the nearest multiple of 5.
#
# Source: http://familysearch.org/learn/wiki/en/England_Census:_Further_Information_and_Description
adjustment = -1 if myage > 6
elsif census_year == RecordType::CENSUS_1851
# Census day: March 30, 1851
adjustment = -1 if myage > 3
elsif census_year == RecordType::CENSUS_1861
# Census day: April 7, 1861
adjustment = -1 if myage > 4
elsif census_year == RecordType::CENSUS_1871
# Census day: April 2, 1871
adjustment = -1 if myage > 4
elsif census_year == RecordType::CENSUS_1881
# Census day: April 3, 1881
adjustment = -1 if myage > 4
elsif census_year == RecordType::CENSUS_1891
# Census day: April 5, 1891
adjustment = -1 if myage > 4
end
end
else
adjustment = 0 - myage
end
birth_year = census_year.to_i + adjustment
"#{birth_year}-*-*"
end

def translate_date_old
myage = age.to_i
census_year = year
adjustment = 0 # this is all we need to do for day and week age units
Expand Down
3 changes: 2 additions & 1 deletion app/models/physical_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def upload_report_mail(start_date, end_date)
uploaders_count = uploders_role.group_by(&:itself).transform_values(&:count)
email_confirmed = UseridDetail.where(email_address_last_confirmned: start_date..end_date)
users_count = UseridDetail.where(c_at: start_date..end_date)
[uploaders_count, email_confirmed, users_count]
total_records_added = SiteStatistic.where(year: start_date.year, month: start_date.month).sum(:n_records_added)
[uploaders_count, email_confirmed, users_count, total_records_added]
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>Dear <%= @user.userid%></p>
<p>You had submitted some feedback to <%= @appname %> reference
<a href="<%=Rails.application.config.website%>/feedbacks/<%=@feedback.id%>"><%= @feedback.identifier %></a>
to us with the title <b><%= @feedback.title%></b> at <%= @feedback.feedback_time.strftime("%H:%M on %F") unless @feedback.feedback_time.nil?%></p>
<p>This email is to notify you that we have created an github issue and you can monitor the progess here: <%= link_to "link to github issue", @feedback.github_issue_url %></p>
47 changes: 17 additions & 30 deletions app/views/user_mailer/send_upload_stats.html.erb
Original file line number Diff line number Diff line change
@@ -1,49 +1,36 @@
<html>
<p>Hello Everyone,</p>
<p>Please find the upload report for the month of <%= @start_date.strftime('%B')%></p>
<p>Here is the upload report for the month of <%= @start_date.strftime('%B')%></p>
<div class="scrollable">
<table style="border: 1px solid black;">
<caption>
<strong>Basic information</strong>
<strong><p>Upload report by members</p></strong>
</caption>
<thead>
<tr>
<th scope="col" style="border: 1px solid black;">Detail</th>
<th scope="col" style="border: 1px solid black;">Count</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" style="border: 1px solid black;">Total active transcribers</th>
<td style="border: 1px solid black;"><%= @active_transcribers_count %></td>
</tr>
<tr>
<th style="border: 1px solid black; padding: 5px;">Time Period</th>
<th style="border: 1px solid black; padding: 5px;">Roles</th>
<th style="border: 1px solid black; padding: 5px">Upload Count</th>
</tr>
<% @uploaders_count.each do |u| %>
<tr>
<th scope="row" style="border: 1px solid black;">Number of transcribers with their email address confirmed in this period.</th>
<td style="border: 1px solid black;"><%= @email_confimed %></td>
<td style="border: 1px solid black; padding: 5px;"><%= "#{@start_date.to_date.strftime("%B, %d, %Y")} - #{@end_date.to_date.strftime("%B, %d, %Y")}" %></td>
<td style="border: 1px solid black; padding: 5px;">
<%= u[0].split('_').map(&:titlecase).join(' ') %>
</td>
<td style="border: 1px solid black; padding: 5px;"><%= u[1] %></td>
</tr>
</tbody>
<% end %>
</table>
</div>

<div class="scrollable">
<table style="border: 1px solid black;">
<caption>
<strong><p>Upload report by members</p></strong>
<strong><p>Database Additions</p></strong>
</caption>
<tr>
<th style="border: 1px solid black;">Time Period</th>
<th style="border: 1px solid black;">Roles</th>
<th style="border: 1px solid black;">Upload Count</th>
<th style="border: 1px solid black; padding: 5px;">New Records added</th>
<td style="border: 1px solid black; padding: 5px;"><%= number_with_delimiter(@records_added) %></td>
</tr>
<% @uploaders_count.each do |u| %>
<tr>
<td style="border: 1px solid black;"><%= "#{@start_date.to_date.strftime("%B, %d, %Y")} - #{@end_date.to_date.strftime("%B, %d, %Y")}" %></td>
<td style="border: 1px solid black;">
<%= u[0].split('_').map(&:titlecase).join(' ') %>
</td>
<td style="border: 1px solid black;"><%= u[1] %></td>
</tr>
<% end %>
</table>
</div>
</html>

0 comments on commit e4b2ed6

Please sign in to comment.