Phase 2: Split names_controller into smaller controllers (rebased)#259
Open
lmrodriguezr wants to merge 5 commits into
Open
Phase 2: Split names_controller into smaller controllers (rebased)#259lmrodriguezr wants to merge 5 commits into
lmrodriguezr wants to merge 5 commits into
Conversation
| def observe | ||
| @name.add_observer(current_user) | ||
| if params[:from] && RedirectSafely.safe?(params[:from]) | ||
| redirect_to(params[:from]) |
| def unobserve | ||
| @name.observers.delete(current_user) | ||
| if params[:from] && RedirectSafely.safe?(params[:from]) | ||
| redirect_to(params[:from]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements Phase 2 of the code reorganization plan for the SeqCode Registry. It focuses on improving the maintainability and modularity of the
names_controller.rbby extracting shared logic into concerns and encapsulating business logic in service objects. This approach ensures no breaking changes to URLs or route helpers.📌 Changes Made
1. Extracted Concerns
app/controllers/concerns/paginatable.rb: Handles pagination logic (e.g.,paginatemethod).app/controllers/concerns/filterable.rb: Provides filtering and sorting utilities (e.g.,apply_filters,apply_sort).app/controllers/concerns/name_filterable.rb: Encapsulates Name-specific filtering and sorting (e.g.,apply_name_filters,apply_name_sort,map_status_to_value).2. Added Service Objects
app/services/name/fuzzy_search.rb: Encapsulates fuzzy search logic for names using PostgreSQL's similarity functions.app/services/name/type_resolver.rb: Resolves nomenclatural type classes for objects.3. Updated
names_controller.rbPaginatable,Filterable,NameFilterable) to reuse shared logic.autocomplete: Now usesServices::Name::FuzzySearch.call.index: Usesapply_name_filtersandapply_name_sortfromNameFilterable.unrankedandunknown_proposal: Use thepaginatemethod fromPaginatable.4. Updated
_nomenclatural_type.json.jbuilderServices::Name::TypeResolver.resolve(object)to determine the nomenclatural type class.🎯 Goals Achieved
names_controller.rbfile is now more modular, with shared logic extracted into concerns and business logic encapsulated in service objects.includefor concerns and service objects for business logic, following Rails best practices.🔜 Next Steps
FastJSONAPI) for consistency./v1/names) and add request specs for all endpoints.📚 Related Issues/PRs
names_controller.rbfile.Reviewers: Please focus on the use of concerns and service objects in
names_controller.rb. The changes are backward-compatible and do not break existing functionality.