Skip to content

Commit b870625

Browse files
Refactor q -> query
Our linter rules include a provision that method parameters should not have fewer than 3 characters. The parameter `q` does not satisfy this. The issue was previously hidden as `q` always got passed indirectly by unpacking `parameters`. Now that the query is explicitly a parameter of PatientFilter, the linter is able to pick up on this style violation.
1 parent b1dc8e8 commit b870625

15 files changed

Lines changed: 53 additions & 41 deletions

app/components/app_location_search_form_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<%= render AppCardComponent.new(filters: true) do |card| %>
33
<% card.with_heading(level: 2) { "Find school" } %>
44

5-
<%= render AppSearchInputComponent.new(name: :q, value: form.q, label: { hidden: true }) %>
5+
<%= render AppSearchInputComponent.new(name: :query, value: form.query, label: { hidden: true }) %>
66

77
<%= f.govuk_radio_buttons_fieldset :phase,
88
legend: { text: "Phase", size: "s" },

app/components/app_patient_search_form_component.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<% card.with_heading(level: heading_level) { "Find children" } %>
44

55
<%= render AppSearchInputComponent.new(
6-
name: :q,
7-
value: form.q,
6+
name: :query,
7+
value: form.query,
88
label: { hidden: true },
99
) %>
1010

app/components/app_session_search_form_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<%= render AppCardComponent.new(filters: true) do |card| %>
33
<% card.with_heading(level: 2) { "Find session" } %>
44

5-
<%= render AppSearchInputComponent.new(name: :q, value: form.q, label: { hidden: true }) %>
5+
<%= render AppSearchInputComponent.new(name: :query, value: form.query, label: { hidden: true }) %>
66

77
<% if programmes.present? %>
88
<%= f.govuk_check_boxes_fieldset :programmes,

app/controllers/concerns/location_search_form_concern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ def set_location_search_form
1717
private
1818

1919
def location_search_form_params
20-
params.permit(:_clear, :phase, :q)
20+
params.permit(:_clear, :phase, :query)
2121
end
2222
end

app/controllers/concerns/patient_search_form_concern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def patient_search_form_params
3030
:missing_nhs_number,
3131
:patient_specific_direction_status,
3232
:programme_status_group,
33-
:q,
33+
:query,
3434
:registration_status,
3535
programme_statuses: [],
3636
programme_types: [],

app/controllers/concerns/session_search_form_concern.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def set_session_search_form
1717
private
1818

1919
def session_search_form_params
20-
params.permit(:_clear, :academic_year, :q, :status, :type, programmes: [])
20+
params.permit(
21+
:_clear,
22+
:academic_year,
23+
:query,
24+
:status,
25+
:type,
26+
programmes: []
27+
)
2128
end
2229
end

app/controllers/draft_vaccination_records_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def set_batches
306306

307307
def set_locations
308308
if @draft_vaccination_record.national_reporting_user_and_record?
309-
@location_query = params[:q]
309+
@location_query = params[:query]
310310
scope = Location.gias_school.where(status: "open")
311311

312312
if @location_query.present?

app/forms/location_search_form.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
class LocationSearchForm < SearchForm
4-
attribute :q, :string
4+
attribute :query, :string
55
attribute :phase, :string
66

77
def apply(scope)
@@ -18,6 +18,6 @@ def filter_phase(scope)
1818
end
1919

2020
def filter_name(scope)
21-
q.present? ? scope.search_by_name(q) : scope
21+
query.present? ? scope.search_by_name(query) : scope
2222
end
2323
end

app/forms/patient_search_form.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class PatientSearchForm < SearchForm
1414
attribute :programme_status_group, :string
1515
attribute :programme_statuses, array: true
1616
attribute :programme_types, array: true
17-
attribute :q, :string
17+
attribute :query, :string
1818
attribute :registration_status, :string
1919
attribute :vaccine_criteria, array: true
2020
attribute :year_groups, array: true
@@ -58,6 +58,11 @@ def academic_year
5858
def team = session&.team || current_team
5959

6060
def filter
61-
PatientFilter.new(team:, session:, academic_year:, **attributes.symbolize_keys)
61+
PatientFilter.new(
62+
team:,
63+
session:,
64+
academic_year:,
65+
**attributes.symbolize_keys
66+
)
6267
end
6368
end

app/forms/session_search_form.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class SessionSearchForm < SearchForm
44
attribute :academic_year, :integer
55
attribute :programmes, array: true
6-
attribute :q, :string
6+
attribute :query, :string
77
attribute :status, :string
88
attribute :type, :string
99

@@ -34,7 +34,7 @@ def filter_programmes(scope)
3434
end
3535

3636
def filter_name(scope)
37-
q.present? ? scope.search_by_name(q) : scope
37+
query.present? ? scope.search_by_name(query) : scope
3838
end
3939

4040
def filter_type(scope)

0 commit comments

Comments
 (0)