-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
feat(#5579): add topics to reports #5601
Changes from 5 commits
6377f2b
182f83e
4c958dd
c5080a4
2647fe9
e47424a
c34f53b
3bb5bca
65f83bc
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 |
---|---|---|
|
@@ -25,7 +25,8 @@ def context | |
latest_hearing_date: latest_hearing_date, | ||
org_address: org_address(@path_to_template), | ||
volunteer: volunteer_info, | ||
hearing_type_name: @court_date&.hearing_type&.name || "None" | ||
hearing_type_name: @court_date&.hearing_type&.name || "None", | ||
case_topics: court_topics.values | ||
} | ||
end | ||
|
||
|
@@ -88,6 +89,51 @@ def org_address(path_to_template) | |
@volunteer.casa_org.address if @volunteer && is_default_template | ||
end | ||
|
||
# Sample output | ||
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. good comment :) |
||
# | ||
# expected_topics = { | ||
# "Question 1" => {topic: "Question 1", details: "Details 1", answers: [ | ||
# {date: "12/02/20", medium: "Type A1, Type B1", value: "Answer 1"}, | ||
# {date: "12/03/20", medium: "Type A2, Type B2", value: "Answer 3"} | ||
# ]}, | ||
# "Question 2" => {topic: "Question 2", details: "Details 2", answers: [ | ||
# {date: "12/02/20", medium: "Type A1, Type B1", value: "Answer 2"}, | ||
# {date: "12/04/20", medium: "Type A3, Type B3", value: "Answer 5"} | ||
# ]}, | ||
# "Question 3" => {topic: "Question 3", details: "Details 3", answers: [ | ||
# {date: "12/03/20", medium: "Type A2, Type B2", value: "No Answer Provided"}, | ||
# {date: "12/04/20", medium: "Type A3, Type B3", value: "No Answer Provided"} | ||
# ]} | ||
# } | ||
def court_topics | ||
topics = ContactTopic | ||
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. nice query. It could be slow but we are working with small numbers I think we're fine |
||
.joins(contact_topic_answers: {case_contact: [:casa_case, :contact_types]}).distinct | ||
.where("casa_cases.id": @casa_case.id) | ||
.where("case_contacts.occurred_at": @date_range) | ||
.order(:occurred_at, :value) | ||
.select(:details, :question, :occurred_at, :value, :contact_made, | ||
"STRING_AGG(contact_types.name, ', ' ORDER BY contact_types.name) AS medium_types") | ||
.group(:details, :question, :occurred_at, :value, :contact_made) | ||
|
||
topics.each_with_object({}) do |topic, hash| | ||
hash[topic.question] ||= { | ||
answers: [], | ||
topic: topic.question, | ||
details: topic.details | ||
} | ||
|
||
formatted_date = CourtReportFormatContactDate.new(topic).format_long | ||
answer_value = topic.value.blank? ? "No Answer Provided" : topic.value | ||
answer = { | ||
date: formatted_date, | ||
medium: topic.medium_types, | ||
value: answer_value | ||
} | ||
|
||
hash[topic.question][:answers].push(answer) | ||
end | ||
end | ||
|
||
private | ||
|
||
def calculate_date_range(args) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,8 +136,9 @@ | |
<% end %> | ||
<% end %> | ||
</ol> | ||
|
||
<button type="button" class="btn-sm main-btn primary-btn-outline btn-hover" id="add-another-expense">+ Add Another Expense</button> | ||
<% if @case_contact.decorate.additional_expenses_count < 10 %> | ||
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. good improvement limit 10 |
||
<button type="button" class="btn-sm main-btn primary-btn-outline btn-hover" id="add-another-expense">+ Add Another Expense</button> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace :after_party do | ||
desc "Deployment task: Updates_production_casa_orgs_with_new_templates" | ||
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. scary but good |
||
task update_org_templates: :environment do | ||
puts "Running deploy task 'update_org_templates'" | ||
|
||
mapping = { | ||
"Howard County CASA" => "howard_county_report_template.docx", | ||
"Voices for Children Montgomery" => "montgomery_report_template.docx", | ||
"Prince George CASA" => "prince_george_report_template.docx" | ||
} | ||
|
||
mapping.each do |casa_org_name, template_file_name| | ||
casa_org = CasaOrg.find_by(name: casa_org_name) | ||
if casa_org | ||
casa_org.court_report_template.attach( | ||
io: File.new(Rails.root.join("app", "documents", "templates", template_file_name)), | ||
filename: template_file_name | ||
) | ||
else | ||
Bugsnag.notify("No #{casa_org_name} found for rake task update_org_templates") | ||
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. good notify! |
||
end | ||
end | ||
|
||
# Update task as completed. If you remove the line below, the task will | ||
# run with every deploy (or every time you call after_party:run). | ||
AfterParty::TaskRecord | ||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp | ||
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.
Why did this one get smaller? Seems strange and maybe not good
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.
No clue. The template got longer so that's weird.
old:
new: