From b5823163343ab63bb72068beedbb88d602388726 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 23 Sep 2024 10:42:00 +0100 Subject: [PATCH 1/3] Increase the results limit to 15 We have found that the current value is somewhat restrictive when searching large cities like London, as it hides hubs that would typically be expected to appear. --- app/lib/local_authority/search.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/lib/local_authority/search.rb b/app/lib/local_authority/search.rb index e705e1e..ec21484 100644 --- a/app/lib/local_authority/search.rb +++ b/app/lib/local_authority/search.rb @@ -1,4 +1,6 @@ class LocalAuthority::Search + RESULT_LIMIT = 15 + def initialize(scope, query) @scope = scope @query = query @@ -12,7 +14,7 @@ def call if search_polygon result.where("ST_Intersects(geometry, ?)", search_polygon) else - result.limit(5) + result.limit(RESULT_LIMIT) end end From df55c902d1d5fde9ec7feb66f0d23a300a442edd Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 23 Sep 2024 15:47:30 +0100 Subject: [PATCH 2/3] Update the specs --- Gemfile.lock | 3 +++ spec/features/happy_path_spec.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4542764..043dcf6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -180,6 +180,8 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) nokogiri (1.16.6-x86_64-darwin) racc (~> 1.4) nokogiri (1.16.6-x86_64-linux) @@ -364,6 +366,7 @@ GEM zeitwerk (2.6.16) PLATFORMS + arm64-darwin-23 x86_64-darwin-20 x86_64-darwin-23 x86_64-linux diff --git a/spec/features/happy_path_spec.rb b/spec/features/happy_path_spec.rb index 94f4dad..1a96184 100644 --- a/spec/features/happy_path_spec.rb +++ b/spec/features/happy_path_spec.rb @@ -7,7 +7,7 @@ end let(:expected_hubs_names) do - ["Chiltern Teaching School Hub", "Chiltern Teaching School Hub", "Alban Teaching School Hub"] + ["Chiltern Teaching School Hub", "Chiltern Teaching School Hub", "Alban Teaching School Hub", "Astra Teaching School Hub, Buckinghamshire", "Cambridgeshire and Peterborough Teaching School Hub"] end scenario "Performs search" do From 2dae813a8e21fd445c3aa3a529c8ccb97c474296 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Mon, 23 Sep 2024 15:50:16 +0100 Subject: [PATCH 3/3] Fix linter issues --- spec/features/happy_path_spec.rb | 47 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/spec/features/happy_path_spec.rb b/spec/features/happy_path_spec.rb index 1a96184..dac7614 100644 --- a/spec/features/happy_path_spec.rb +++ b/spec/features/happy_path_spec.rb @@ -1,23 +1,24 @@ -require "rails_helper" - -RSpec.feature "Happy path", type: :feature do - before do - LocalAuthority::Importer.new.reload! - Hub::Importer.new.reload! - end - - let(:expected_hubs_names) do - ["Chiltern Teaching School Hub", "Chiltern Teaching School Hub", "Alban Teaching School Hub", "Astra Teaching School Hub, Buckinghamshire", "Cambridgeshire and Peterborough Teaching School Hub"] - end - - scenario "Performs search" do - VCR.use_cassette("geocoder") do - visit root_path - expect(page).to have_text("Where do you want to find teaching school hubs?") - fill_in "Where do you want to find teaching school hubs?", with: "Luton" - click_button('Continue') - hubs = all('h2 a').map(&:text) - expect(hubs).to eq(expected_hubs_names) - end - end -end +require "rails_helper" + +RSpec.feature "Happy path", type: :feature do + before do + LocalAuthority::Importer.new.reload! + Hub::Importer.new.reload! + end + + let(:expected_hubs_names) do + ["Chiltern Teaching School Hub", "Chiltern Teaching School Hub", "Alban Teaching School Hub", + "Astra Teaching School Hub, Buckinghamshire", "Cambridgeshire and Peterborough Teaching School Hub"] + end + + scenario "Performs search" do + VCR.use_cassette("geocoder") do + visit root_path + expect(page).to have_text("Where do you want to find teaching school hubs?") + fill_in "Where do you want to find teaching school hubs?", with: "Luton" + click_button('Continue') + hubs = all('h2 a').map(&:text) + expect(hubs).to eq(expected_hubs_names) + end + end +end