Skip to content

Commit 4886255

Browse files
committed
Merge branch 'main' of https://github.com/Budmin/casa into 6600_volunteer_emailsave
2 parents 57eeec6 + dc6ac28 commit 4886255

File tree

16 files changed

+1623
-23
lines changed

16 files changed

+1623
-23
lines changed

.github/workflows/combine_and_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: actions/checkout@v6
1414
- name: Download artifacts
1515
if: ${{ !cancelled() }}
16-
uses: actions/download-artifact@v6
16+
uses: actions/download-artifact@v7
1717
with:
1818
path: artifacts
1919

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
- name: Archive selenium screenshots
4545
if: ${{ failure() }}
46-
uses: actions/upload-artifact@v5
46+
uses: actions/upload-artifact@v6
4747
with:
4848
name: selenium-screenshots
4949
path: |

.github/workflows/rspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686

8787
- name: Archive selenium screenshots
8888
if: ${{ failure() }}
89-
uses: actions/upload-artifact@v5
89+
uses: actions/upload-artifact@v6
9090
with:
9191
name: selenium-screenshots
9292
path: |

Gemfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ GEM
142142
caxlsx_rails (0.6.4)
143143
actionpack (>= 3.1)
144144
caxlsx (>= 3.0)
145-
cgi (0.5.0)
145+
cgi (0.5.1)
146146
childprocess (5.1.0)
147147
logger (~> 1.5)
148148
cliver (0.3.2)
@@ -160,7 +160,7 @@ GEM
160160
activerecord (>= 5.a)
161161
database_cleaner-core (~> 2.0)
162162
database_cleaner-core (2.0.1)
163-
date (3.5.0)
163+
date (3.5.1)
164164
delayed_job (4.1.13)
165165
activesupport (>= 3.0, < 9.0)
166166
delayed_job_active_record (4.1.11)
@@ -285,7 +285,7 @@ GEM
285285
image_processing (1.14.0)
286286
mini_magick (>= 4.9.5, < 6)
287287
ruby-vips (>= 2.0.17, < 3)
288-
io-console (0.8.1)
288+
io-console (0.8.2)
289289
irb (1.15.3)
290290
pp (>= 0.6.0)
291291
rdoc (>= 4.0.0)
@@ -334,7 +334,7 @@ GEM
334334
logger
335335
mini_mime (1.1.5)
336336
mini_portile2 (2.8.9)
337-
minitest (5.26.2)
337+
minitest (5.27.0)
338338
multi_xml (0.7.1)
339339
bigdecimal (~> 3.1)
340340
multipart-post (2.4.1)
@@ -427,7 +427,7 @@ GEM
427427
pry-byebug (3.11.0)
428428
byebug (~> 12.0)
429429
pry (>= 0.13, < 0.16)
430-
psych (5.2.6)
430+
psych (5.3.0)
431431
date
432432
stringio
433433
public_suffix (7.0.0)
@@ -489,7 +489,7 @@ GEM
489489
tsort (>= 0.2)
490490
zeitwerk (~> 2.6)
491491
rainbow (3.1.1)
492-
rake (13.3.0)
492+
rake (13.3.1)
493493
rdoc (6.17.0)
494494
erb
495495
psych (>= 4.0.0)
@@ -650,7 +650,7 @@ GEM
650650
traceroute (0.8.1)
651651
rails (>= 3.0.0)
652652
tsort (0.2.0)
653-
turbo-rails (2.0.17)
653+
turbo-rails (2.0.20)
654654
actionpack (>= 7.1.0)
655655
railties (>= 7.1.0)
656656
twilio-ruby (7.8.3)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Users::InvitationsController < Devise::InvitationsController
2+
# Override the edit action to ensure the invitation_token is properly set in the form
3+
def edit
4+
self.resource = resource_class.new
5+
set_minimum_password_length if respond_to?(:set_minimum_password_length, true)
6+
resource.invitation_token = params[:invitation_token]
7+
render :edit
8+
end
9+
end
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# frozen_string_literal: true
2+
3+
class CaseContactDatatable < ApplicationDatatable
4+
ORDERABLE_FIELDS = %w[
5+
occurred_at
6+
contact_made
7+
medium_type
8+
duration_minutes
9+
].freeze
10+
11+
private
12+
13+
def data
14+
records.map do |case_contact|
15+
{
16+
id: case_contact.id,
17+
occurred_at: I18n.l(case_contact.occurred_at, format: :full, default: nil),
18+
casa_case: {
19+
id: case_contact.casa_case_id,
20+
case_number: case_contact.casa_case&.case_number
21+
},
22+
contact_types: case_contact.contact_types.map(&:name).join(", "),
23+
medium_type: case_contact.medium_type&.titleize,
24+
creator: {
25+
id: case_contact.creator_id,
26+
display_name: case_contact.creator&.display_name,
27+
email: case_contact.creator&.email,
28+
role: case_contact.creator&.role
29+
},
30+
contact_made: case_contact.contact_made,
31+
duration_minutes: case_contact.duration_minutes,
32+
contact_topics: case_contact.contact_topics.map(&:question).join(" | "),
33+
is_draft: !case_contact.active?,
34+
has_followup: case_contact.followups.requested.exists?
35+
}
36+
end
37+
end
38+
39+
def filtered_records
40+
raw_records.where(search_filter)
41+
end
42+
43+
def raw_records
44+
base_relation
45+
.joins("INNER JOIN users creators ON creators.id = case_contacts.creator_id")
46+
.left_joins(:casa_case)
47+
.includes(:contact_types, :contact_topics, :followups, :creator)
48+
.order(order_clause)
49+
.order(:id)
50+
end
51+
52+
def search_filter
53+
return "TRUE" if search_term.blank?
54+
55+
ilike_fields = %w[
56+
creators.display_name
57+
creators.email
58+
casa_cases.case_number
59+
case_contacts.notes
60+
]
61+
62+
ilike_clauses = ilike_fields.map { |field| "#{field} ILIKE ?" }.join(" OR ")
63+
contact_type_clause = "case_contacts.id IN (#{contact_type_search_subquery})"
64+
65+
full_clause = "#{ilike_clauses} OR #{contact_type_clause}"
66+
[full_clause, ilike_fields.count.times.map { "%#{search_term}%" }].flatten
67+
end
68+
69+
def contact_type_search_subquery
70+
@contact_type_search_subquery ||= lambda {
71+
return "SELECT NULL WHERE FALSE" if search_term.blank?
72+
73+
CaseContact
74+
.select("DISTINCT case_contacts.id")
75+
.joins(case_contact_contact_types: :contact_type)
76+
.where("contact_types.name ILIKE ?", "%#{search_term}%")
77+
.to_sql
78+
}.call
79+
end
80+
81+
def order_clause
82+
@order_clause ||= build_order_clause
83+
end
84+
end

0 commit comments

Comments
 (0)