From 9127391ea273b7a85e0ec1e1c5a93b7b8321687f Mon Sep 17 00:00:00 2001 From: Jeff Marks Date: Mon, 25 Nov 2024 14:23:09 -0700 Subject: [PATCH 1/6] Update search client/config to use mocks if program type is flight --- lib/gi/search_client.rb | 8 ++++++++ lib/gi/search_configuration.rb | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/lib/gi/search_client.rb b/lib/gi/search_client.rb index bdb1528c565..86dd50eb657 100644 --- a/lib/gi/search_client.rb +++ b/lib/gi/search_client.rb @@ -8,12 +8,20 @@ module GI class SearchClient < GI::Client configuration GI::SearchConfiguration + FLIGHT_PROGRAM_TYPE = 'FLGT' + def get_institution_search_results_v0(params = {}) response = perform(:get, 'v0/institutions', params) gids_response(response) end def get_institution_program_search_results_v0(params = {}) + # Mock response if querying for flight school programs + # TO-DO: Remove after flight school program data becomes accessible + if params[:type] == FLIGHT_PROGRAM_TYPE + config.instance_variable_set(:@program_type_flight, true) + end + response = perform(:get, 'v0/institution_programs', params) gids_response(response) end diff --git a/lib/gi/search_configuration.rb b/lib/gi/search_configuration.rb index f2124999100..9b84b806004 100644 --- a/lib/gi/search_configuration.rb +++ b/lib/gi/search_configuration.rb @@ -4,5 +4,11 @@ module GI class SearchConfiguration < GI::Configuration self.read_timeout = Settings.gids.search&.read_timeout || 4 self.open_timeout = Settings.gids.search&.open_timeout || 4 + + # Mock response if querying for flight school programs + # TO-DO: Remove after flight school program data becomes accessible + def use_mocks? + (@program_type_flight && Settings.gids.use_mocks) || false + end end end From 0685c635730028d7a27b822e4faadabb5fdd5cd9 Mon Sep 17 00:00:00 2001 From: Jeff Marks Date: Wed, 27 Nov 2024 12:39:52 -0700 Subject: [PATCH 2/6] Update betamocks setting --- config/betamocks/services_config.yml | 7 +++++++ config/settings.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/config/betamocks/services_config.yml b/config/betamocks/services_config.yml index 2bdf997c445..3e29c582c21 100644 --- a/config/betamocks/services_config.yml +++ b/config/betamocks/services_config.yml @@ -941,6 +941,13 @@ - :name: "GIDS" :base_uri: <%= "#{URI(Settings.gids.url).host}:#{URI(Settings.gids.url).port}" %> :endpoints: + - :method: :get + :path: "/gids/v0/institution_programs" + :file_path: "gids/programs" + # Mock only enabled when filtering by flight programs, see: lib/gi/search_client.rb + :cache_multiple_responses: + :uid_location: query + :uid_locator: type - :method: :get :path: "/gids/v1/lce" :file_path: "gids/lce" diff --git a/config/settings.yml b/config/settings.yml index ae6ac19c385..7ad9468ee92 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -489,6 +489,7 @@ gids: url: https://dev.va.gov/gids open_timeout: 1 read_timeout: 1 + use_mocks: false lce: use_mocks: false From 51954f3c6c009f0fe565adc110f3f2d8e46ab7ef Mon Sep 17 00:00:00 2001 From: Jeff Marks Date: Wed, 27 Nov 2024 13:18:51 -0700 Subject: [PATCH 3/6] Update namespace --- config/settings.yml | 3 ++- lib/gi/search_configuration.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/settings.yml b/config/settings.yml index 7ad9468ee92..4f6ede2d0ab 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -489,7 +489,8 @@ gids: url: https://dev.va.gov/gids open_timeout: 1 read_timeout: 1 - use_mocks: false + search: + use_mocks: false lce: use_mocks: false diff --git a/lib/gi/search_configuration.rb b/lib/gi/search_configuration.rb index 9b84b806004..1b9efc2dda8 100644 --- a/lib/gi/search_configuration.rb +++ b/lib/gi/search_configuration.rb @@ -8,7 +8,7 @@ class SearchConfiguration < GI::Configuration # Mock response if querying for flight school programs # TO-DO: Remove after flight school program data becomes accessible def use_mocks? - (@program_type_flight && Settings.gids.use_mocks) || false + (@program_type_flight && Settings.gids.search.use_mocks) || false end end end From f17439264adbe1394073590d4a81b41aaf18f291 Mon Sep 17 00:00:00 2001 From: Jeff Marks Date: Wed, 27 Nov 2024 13:41:00 -0700 Subject: [PATCH 4/6] Add guard clause to search use mocks --- lib/gi/search_configuration.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/gi/search_configuration.rb b/lib/gi/search_configuration.rb index 1b9efc2dda8..74f2e2495e4 100644 --- a/lib/gi/search_configuration.rb +++ b/lib/gi/search_configuration.rb @@ -8,7 +8,10 @@ class SearchConfiguration < GI::Configuration # Mock response if querying for flight school programs # TO-DO: Remove after flight school program data becomes accessible def use_mocks? - (@program_type_flight && Settings.gids.search.use_mocks) || false + return false unless instance_variable_defined?(:@program_type_flight) + + querying_by_flight = remove_instance_variable(:@program_type_flight) + querying_by_flight && Settings.gids.search.use_mocks || false end end end From 474146e60d7a909f38495eaed567e145bd23949a Mon Sep 17 00:00:00 2001 From: Jeff Marks Date: Wed, 27 Nov 2024 13:44:52 -0700 Subject: [PATCH 5/6] Linting --- lib/gi/search_client.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/gi/search_client.rb b/lib/gi/search_client.rb index 86dd50eb657..0a57a92c4c5 100644 --- a/lib/gi/search_client.rb +++ b/lib/gi/search_client.rb @@ -8,8 +8,6 @@ module GI class SearchClient < GI::Client configuration GI::SearchConfiguration - FLIGHT_PROGRAM_TYPE = 'FLGT' - def get_institution_search_results_v0(params = {}) response = perform(:get, 'v0/institutions', params) gids_response(response) @@ -18,9 +16,7 @@ def get_institution_search_results_v0(params = {}) def get_institution_program_search_results_v0(params = {}) # Mock response if querying for flight school programs # TO-DO: Remove after flight school program data becomes accessible - if params[:type] == FLIGHT_PROGRAM_TYPE - config.instance_variable_set(:@program_type_flight, true) - end + config.instance_variable_set(:@program_type_flight, true) if params[:type] == 'FLGT' response = perform(:get, 'v0/institution_programs', params) gids_response(response) From ba451d8aeacff0fc556d7709945803edb7647c03 Mon Sep 17 00:00:00 2001 From: Jeff Marks Date: Fri, 29 Nov 2024 07:50:37 -0700 Subject: [PATCH 6/6] Linting --- lib/gi/search_configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gi/search_configuration.rb b/lib/gi/search_configuration.rb index 74f2e2495e4..63f35628ee8 100644 --- a/lib/gi/search_configuration.rb +++ b/lib/gi/search_configuration.rb @@ -11,7 +11,7 @@ def use_mocks? return false unless instance_variable_defined?(:@program_type_flight) querying_by_flight = remove_instance_variable(:@program_type_flight) - querying_by_flight && Settings.gids.search.use_mocks || false + (querying_by_flight && Settings.gids.search.use_mocks) || false end end end