Class: BranchNameListService
- Inherits:
-
Object
- Object
- BranchNameListService
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/services/branch_name_list_service.rb
Overview
Service class to handle branch listing with name filtering only Provides pagination, filtering by name, and caching capabilities for branch data Does not include master menu filtering unlike BranchListService
Instance Method Summary collapse
-
#cache_key ⇒ String
Generate cache key for caching the response.
-
#call ⇒ Hash
Execute the branch listing logic with name filtering only.
-
#initialize(params) ⇒ BranchNameListService
constructor
A new instance of BranchNameListService.
Constructor Details
#initialize(params) ⇒ BranchNameListService
Returns a new instance of BranchNameListService.
7 8 9 |
# File 'app/services/branch_name_list_service.rb', line 7 def initialize(params) @params = params end |
Instance Method Details
#cache_key ⇒ String
Generate cache key for caching the response
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/branch_name_list_service.rb', line 13 def cache_key [ self.class.to_s, CityHash.hash32(@params), 'branch_name_lists', I18n.locale, @params[:name_like], "page:#{page}", "per_page:#{per_page}", "updated_at:#{Branch.maximum(:updated_at).to_i}", ].join('|') end |
#call ⇒ Hash
Execute the branch listing logic with name filtering only
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/branch_name_list_service.rb', line 28 def call branches = filter_active_branches branches = apply_name_filter(branches) if @params[:name_like].present? paginated_result = paginate_branches(branches) branches_data = format_branches_data(paginated_result[:branches]) build_response(branches_data, paginated_result[:pagination]) rescue StandardError => e HH_LOGGER.error('Error in BranchNameListService#call', { error: e., params: @params }) APMErrorHandler.report(e, context: { params: @params }) { success: false, message: 'Failed to fetch branches' } end |