From 0482938020e2fdb1c84caeb051fa0493b01ff5c2 Mon Sep 17 00:00:00 2001 From: Seth Herr Date: Wed, 5 Feb 2025 16:58:18 -0800 Subject: [PATCH 1/2] add annotate_rb --- .annotate_rb.yml | 58 +++++++++++++++++++++++++++++ Gemfile | 3 +- Gemfile.lock | 18 ++++----- lib/tasks/annotate_rb.rake | 8 ++++ lib/tasks/auto_annotate_models.rake | 56 ---------------------------- 5 files changed, 75 insertions(+), 68 deletions(-) create mode 100644 .annotate_rb.yml create mode 100644 lib/tasks/annotate_rb.rake delete mode 100644 lib/tasks/auto_annotate_models.rake diff --git a/.annotate_rb.yml b/.annotate_rb.yml new file mode 100644 index 0000000000..99150eff77 --- /dev/null +++ b/.annotate_rb.yml @@ -0,0 +1,58 @@ +--- +:position: before +:position_in_additional_file_patterns: before +:position_in_class: before +:position_in_factory: before +:position_in_fixture: before +:position_in_routes: before +:position_in_serializer: before +:position_in_test: before +:classified_sort: true +:exclude_controllers: true +:exclude_factories: true +:exclude_fixtures: false +:exclude_helpers: true +:exclude_scaffolds: true +:exclude_serializers: true +:exclude_sti_subclasses: false +:exclude_tests: true +:force: false +:format_markdown: false +:format_rdoc: false +:format_yard: false +:frozen: false +:ignore_model_sub_dir: false +:ignore_unknown_models: false +:include_version: false +:show_check_constraints: false +:show_complete_foreign_keys: false +:show_foreign_keys: true +:show_indexes: true +:simple_indexes: false +:sort: false +:timestamp: false +:trace: false +:with_comment: true +:with_column_comments: true +:with_table_comments: true +:active_admin: false +:command: +:debug: false +:hide_default_column_types: '' +:hide_limit_column_types: '' +:ignore_columns: +:ignore_routes: +:models: true +:routes: false +:skip_on_db_migrate: false +:target_action: :do_annotations +:wrapper: +:wrapper_close: +:wrapper_open: +:classes_default_to_s: [] +:additional_file_patterns: [] +:model_dir: +- app/models +:require: [] +:root_dir: +- '' diff --git a/Gemfile b/Gemfile index 6531604904..400b2e9113 100644 --- a/Gemfile +++ b/Gemfile @@ -151,8 +151,7 @@ group :development do gem "letter_opener" gem "rerun" # restart sidekiq processes in development on app change gem "terminal-notifier" - # Use community-maintained fork to support rails 8 - hopefully, eventually mainlined - gem "annotate", github: "bikeindex/annotate_models", branch: "develop" # Annotate models with schema info + gem 'annotate_rb', github: "sethherr/annotate_rb", branch: "rename-annotate_rb" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 51d2665c89..75dbf3b966 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,3 @@ -GIT - remote: https://github.com/bikeindex/annotate_models.git - revision: 8cf2eeaaeee39a00f6b9573485219910da77b9ff - branch: develop - specs: - annotate (3.2.0) - activerecord (>= 3.2) - rake (>= 10.4, < 14.0) - GIT remote: https://github.com/bikeindex/carrierwave_backgrounder.git revision: 7b2b0e9bc43f2ec20f09db3fea7bbc5f167f52c7 @@ -42,6 +33,13 @@ GIT excon (~> 0.76.0) json (~> 2.1, >= 2.1.0) +GIT + remote: https://github.com/sethherr/annotate_rb.git + revision: a947916dff1eab2c1b570a8b57020fb24337c797 + branch: rename-annotate_rb + specs: + annotate_rb (5.0.0) + GEM remote: https://rails-assets.org/ specs: @@ -841,7 +839,7 @@ PLATFORMS DEPENDENCIES MailchimpMarketing! active_model_serializers (~> 0.8.3) - annotate! + annotate_rb! api-pagination axlsx (~> 3.0.0.pre) bcrypt diff --git a/lib/tasks/annotate_rb.rake b/lib/tasks/annotate_rb.rake new file mode 100644 index 0000000000..1ad0ec39e7 --- /dev/null +++ b/lib/tasks/annotate_rb.rake @@ -0,0 +1,8 @@ +# This rake task was added by annotate_rb gem. + +# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this +if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil? + require "annotate_rb" + + AnnotateRb::Core.load_rake_tasks +end diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake deleted file mode 100644 index 07ec490dc3..0000000000 --- a/lib/tasks/auto_annotate_models.rake +++ /dev/null @@ -1,56 +0,0 @@ -# Annotate is only used in development -if Rails.env.development? - require "annotate" - task :set_annotation_options do - # You can override any of these by setting an environment variable of the - # same name. - Annotate.set_defaults( - "active_admin" => "false", - "additional_file_patterns" => [], - "routes" => "false", - "models" => "true", - "position_in_routes" => "before", - "position_in_class" => "before", - "position_in_test" => "before", - "position_in_fixture" => "before", - "position_in_factory" => "before", - "position_in_serializer" => "before", - "show_foreign_keys" => "true", - "show_complete_foreign_keys" => "false", - "show_indexes" => "false", - "simple_indexes" => "false", - "model_dir" => "app/models", - "root_dir" => "", - "include_version" => "false", - "require" => "", - "exclude_tests" => "true", - "exclude_fixtures" => "true", - "exclude_factories" => "true", - "exclude_serializers" => "true", - "exclude_scaffolds" => "true", - "exclude_controllers" => "true", - "exclude_helpers" => "true", - "exclude_sti_subclasses" => "false", - "ignore_model_sub_dir" => "false", - "ignore_columns" => nil, - "ignore_routes" => nil, - "ignore_unknown_models" => "false", - "hide_limit_column_types" => "integer,bigint,boolean", - "hide_default_column_types" => "json,jsonb,hstore", - "skip_on_db_migrate" => "false", - "format_bare" => "true", - "format_rdoc" => "false", - "format_yard" => "false", - "format_markdown" => "false", - "sort" => "false", - "force" => "false", - "frozen" => "false", - "classified_sort" => "true", - "trace" => "false", - "wrapper_open" => nil, - "wrapper_close" => nil, - "with_comment" => "true" - ) - end - Annotate.load_tasks -end From 9450c9988ddd44988155f2fcf528f52af0e55db7 Mon Sep 17 00:00:00 2001 From: Seth Herr Date: Wed, 5 Feb 2025 16:58:49 -0800 Subject: [PATCH 2/2] run annotate_rb --- app/models/logged_search.rb | 8 ++++++++ app/models/organization_status.rb | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/app/models/logged_search.rb b/app/models/logged_search.rb index 95f2d1a193..2d16e842f0 100644 --- a/app/models/logged_search.rb +++ b/app/models/logged_search.rb @@ -28,6 +28,14 @@ # state_id :bigint # user_id :bigint # +# Indexes +# +# index_logged_searches_on_country_id (country_id) +# index_logged_searches_on_organization_id (organization_id) +# index_logged_searches_on_request_id (request_id) +# index_logged_searches_on_state_id (state_id) +# index_logged_searches_on_user_id (user_id) +# class LoggedSearch < AnalyticsRecord include Geocodeable diff --git a/app/models/organization_status.rb b/app/models/organization_status.rb index 184054b3ce..37b2fa9685 100644 --- a/app/models/organization_status.rb +++ b/app/models/organization_status.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # organization_id :bigint # +# Indexes +# +# index_organization_statuses_on_organization_id (organization_id) +# class OrganizationStatus < AnalyticsRecord belongs_to :organization