From 22c7e0cdb63c008ba2f76cdaba9b848c042325e4 Mon Sep 17 00:00:00 2001 From: Mohammad Kanaan Date: Mon, 25 May 2026 19:15:06 +0300 Subject: [PATCH] annotate models --- .annotaterb.yml | 65 ++++++++++++++++++++++++++++++ app/models/admin.rb | 15 +++++++ app/models/chain.rb | 9 +++++ app/models/guest.rb | 10 +++++ app/models/moderation_log.rb | 21 ++++++++++ app/models/price_report.rb | 28 +++++++++++++ app/models/product.rb | 14 +++++++ app/models/store.rb | 20 +++++++++ lib/tasks/annotate_rb.rake | 10 +++++ test/fixtures/admins.yml | 15 +++++++ test/fixtures/chains.yml | 9 +++++ test/fixtures/guests.yml | 10 +++++ test/fixtures/moderation_logs.yml | 21 ++++++++++ test/fixtures/price_reports.yml | 28 +++++++++++++ test/fixtures/products.yml | 16 +++++++- test/fixtures/stores.yml | 20 +++++++++ test/models/admin_test.rb | 15 +++++++ test/models/chain_test.rb | 9 +++++ test/models/guest_test.rb | 10 +++++ test/models/moderation_log_test.rb | 21 ++++++++++ test/models/price_report_test.rb | 28 +++++++++++++ test/models/product_test.rb | 14 +++++++ test/models/store_test.rb | 20 +++++++++ 23 files changed, 427 insertions(+), 1 deletion(-) create mode 100644 .annotaterb.yml create mode 100644 lib/tasks/annotate_rb.rake diff --git a/.annotaterb.yml b/.annotaterb.yml new file mode 100644 index 0000000..dce7215 --- /dev/null +++ b/.annotaterb.yml @@ -0,0 +1,65 @@ +--- +: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: false +:exclude_fixtures: false +:exclude_helpers: true +:exclude_scaffolds: true +:exclude_serializers: false +:exclude_sti_subclasses: false +:exclude_tests: false +:force: false +:format_markdown: false +:format_rdoc: false +:format_yard: false +:frozen: false +:grouped_polymorphic: 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 +:show_indexes_include: false +:simple_indexes: false +:sort: false +:timestamp: false +:trace: false +:with_comment: true +:with_column_comments: true +:with_table_comments: true +:position_of_column_comment: :with_name +:active_admin: false +:command: +:debug: false +:hide_default_column_types: '' +:hide_limit_column_types: '' +:timestamp_columns: +- created_at +- updated_at +:ignore_columns: +:ignore_routes: +:ignore_multi_database_name: false +: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/app/models/admin.rb b/app/models/admin.rb index d581a7b..74bbeff 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -1,2 +1,17 @@ +# == Schema Information +# +# Table name: admins +# +# id :bigint not null, primary key +# email :string +# name :string +# password_digest :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_admins_on_email (email) UNIQUE +# class Admin < ApplicationRecord end diff --git a/app/models/chain.rb b/app/models/chain.rb index a5cdb22..7f5ba9b 100644 --- a/app/models/chain.rb +++ b/app/models/chain.rb @@ -1,3 +1,12 @@ +# == Schema Information +# +# Table name: chains +# +# id :bigint not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# class Chain < ApplicationRecord has_one_attached :image end diff --git a/app/models/guest.rb b/app/models/guest.rb index b7d4d96..5294465 100644 --- a/app/models/guest.rb +++ b/app/models/guest.rb @@ -1,2 +1,12 @@ +# == Schema Information +# +# Table name: guests +# +# id :bigint not null, primary key +# name :string +# username :string +# created_at :datetime not null +# updated_at :datetime not null +# class Guest < ApplicationRecord end diff --git a/app/models/moderation_log.rb b/app/models/moderation_log.rb index e408cfc..0bfd8f5 100644 --- a/app/models/moderation_log.rb +++ b/app/models/moderation_log.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: moderation_logs +# +# id :bigint not null, primary key +# moderatable_type :string not null +# reason :string +# created_at :datetime not null +# updated_at :datetime not null +# admin_id :integer not null +# moderatable_id :integer not null +# +# Indexes +# +# index_moderation_logs_on_admin_id (admin_id) +# index_moderation_logs_on_moderatable (moderatable_type,moderatable_id) +# +# Foreign Keys +# +# fk_rails_... (admin_id => admins.id) +# class ModerationLog < ApplicationRecord belongs_to :moderatable, polymorphic: true belongs_to :admin diff --git a/app/models/price_report.rb b/app/models/price_report.rb index 5513f5e..2e588e4 100644 --- a/app/models/price_report.rb +++ b/app/models/price_report.rb @@ -1,3 +1,31 @@ +# == Schema Information +# +# Table name: price_reports +# +# id :bigint not null, primary key +# discount_price :decimal(, ) +# downvotes :integer +# price :decimal(, ) +# reported_at :datetime +# upvotes :integer +# created_at :datetime not null +# updated_at :datetime not null +# guest_id :integer not null +# product_id :integer not null +# store_id :integer not null +# +# Indexes +# +# index_price_reports_on_guest_id (guest_id) +# index_price_reports_on_product_id (product_id) +# index_price_reports_on_store_id (store_id) +# +# Foreign Keys +# +# fk_rails_... (guest_id => guests.id) +# fk_rails_... (product_id => products.id) +# fk_rails_... (store_id => stores.id) +# class PriceReport < ApplicationRecord belongs_to :product belongs_to :store diff --git a/app/models/product.rb b/app/models/product.rb index c6cf097..2e4df25 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: products +# +# id :bigint not null, primary key +# barcode :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_products_on_barcode (barcode) UNIQUE +# class Product < ApplicationRecord has_one_attached :image end diff --git a/app/models/store.rb b/app/models/store.rb index 67b5460..2277aa3 100644 --- a/app/models/store.rb +++ b/app/models/store.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: stores +# +# id :bigint not null, primary key +# latitude :float +# longitude :float +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# chain_id :integer not null +# +# Indexes +# +# index_stores_on_chain_id (chain_id) +# +# Foreign Keys +# +# fk_rails_... (chain_id => chains.id) +# class Store < ApplicationRecord has_one_attached :image belongs_to :chain diff --git a/lib/tasks/annotate_rb.rake b/lib/tasks/annotate_rb.rake new file mode 100644 index 0000000..c4d4f2d --- /dev/null +++ b/lib/tasks/annotate_rb.rake @@ -0,0 +1,10 @@ +# 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" + + # Can modify the config path here if needed - by default, it's .annotaterb.yml in the root of the project + # AnnotateRb::ConfigFinder.config_path = "" + AnnotateRb::Core.load_rake_tasks +end diff --git a/test/fixtures/admins.yml b/test/fixtures/admins.yml index e2f5253..03a1b0a 100644 --- a/test/fixtures/admins.yml +++ b/test/fixtures/admins.yml @@ -1,5 +1,20 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: admins +# +# id :bigint not null, primary key +# email :string +# name :string +# password_digest :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_admins_on_email (email) UNIQUE +# one: name: MyString email: MyString diff --git a/test/fixtures/chains.yml b/test/fixtures/chains.yml index 7d41224..843c9b2 100644 --- a/test/fixtures/chains.yml +++ b/test/fixtures/chains.yml @@ -1,5 +1,14 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: chains +# +# id :bigint not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# one: name: MyString diff --git a/test/fixtures/guests.yml b/test/fixtures/guests.yml index 35f2967..596094d 100644 --- a/test/fixtures/guests.yml +++ b/test/fixtures/guests.yml @@ -1,5 +1,15 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: guests +# +# id :bigint not null, primary key +# name :string +# username :string +# created_at :datetime not null +# updated_at :datetime not null +# one: username: MyString name: MyString diff --git a/test/fixtures/moderation_logs.yml b/test/fixtures/moderation_logs.yml index 0175942..bf22b9d 100644 --- a/test/fixtures/moderation_logs.yml +++ b/test/fixtures/moderation_logs.yml @@ -1,5 +1,26 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: moderation_logs +# +# id :bigint not null, primary key +# moderatable_type :string not null +# reason :string +# created_at :datetime not null +# updated_at :datetime not null +# admin_id :integer not null +# moderatable_id :integer not null +# +# Indexes +# +# index_moderation_logs_on_admin_id (admin_id) +# index_moderation_logs_on_moderatable (moderatable_type,moderatable_id) +# +# Foreign Keys +# +# fk_rails_... (admin_id => admins.id) +# one: reason: MyString moderatable: one diff --git a/test/fixtures/price_reports.yml b/test/fixtures/price_reports.yml index 00c34ee..3444137 100644 --- a/test/fixtures/price_reports.yml +++ b/test/fixtures/price_reports.yml @@ -1,5 +1,33 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: price_reports +# +# id :bigint not null, primary key +# discount_price :decimal(, ) +# downvotes :integer +# price :decimal(, ) +# reported_at :datetime +# upvotes :integer +# created_at :datetime not null +# updated_at :datetime not null +# guest_id :integer not null +# product_id :integer not null +# store_id :integer not null +# +# Indexes +# +# index_price_reports_on_guest_id (guest_id) +# index_price_reports_on_product_id (product_id) +# index_price_reports_on_store_id (store_id) +# +# Foreign Keys +# +# fk_rails_... (guest_id => guests.id) +# fk_rails_... (product_id => products.id) +# fk_rails_... (store_id => stores.id) +# one: price: 9.99 discount_price: 9.99 diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 770018f..a59ba7e 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -1,5 +1,19 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: products +# +# id :bigint not null, primary key +# barcode :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_products_on_barcode (barcode) UNIQUE +# one: name: MyString - barcode: MyString \ No newline at end of file + barcode: MyString diff --git a/test/fixtures/stores.yml b/test/fixtures/stores.yml index 174193f..15884f5 100644 --- a/test/fixtures/stores.yml +++ b/test/fixtures/stores.yml @@ -1,5 +1,25 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: stores +# +# id :bigint not null, primary key +# latitude :float +# longitude :float +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# chain_id :integer not null +# +# Indexes +# +# index_stores_on_chain_id (chain_id) +# +# Foreign Keys +# +# fk_rails_... (chain_id => chains.id) +# one: name: MyString latitude: 1.5 diff --git a/test/models/admin_test.rb b/test/models/admin_test.rb index 33dd194..e0dd841 100644 --- a/test/models/admin_test.rb +++ b/test/models/admin_test.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: admins +# +# id :bigint not null, primary key +# email :string +# name :string +# password_digest :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_admins_on_email (email) UNIQUE +# require "test_helper" class AdminTest < ActiveSupport::TestCase diff --git a/test/models/chain_test.rb b/test/models/chain_test.rb index c13ee73..f1f2e15 100644 --- a/test/models/chain_test.rb +++ b/test/models/chain_test.rb @@ -1,3 +1,12 @@ +# == Schema Information +# +# Table name: chains +# +# id :bigint not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# require "test_helper" class ChainTest < ActiveSupport::TestCase diff --git a/test/models/guest_test.rb b/test/models/guest_test.rb index e48aed4..827a504 100644 --- a/test/models/guest_test.rb +++ b/test/models/guest_test.rb @@ -1,3 +1,13 @@ +# == Schema Information +# +# Table name: guests +# +# id :bigint not null, primary key +# name :string +# username :string +# created_at :datetime not null +# updated_at :datetime not null +# require "test_helper" class GuestTest < ActiveSupport::TestCase diff --git a/test/models/moderation_log_test.rb b/test/models/moderation_log_test.rb index 75eec93..77d9d76 100644 --- a/test/models/moderation_log_test.rb +++ b/test/models/moderation_log_test.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: moderation_logs +# +# id :bigint not null, primary key +# moderatable_type :string not null +# reason :string +# created_at :datetime not null +# updated_at :datetime not null +# admin_id :integer not null +# moderatable_id :integer not null +# +# Indexes +# +# index_moderation_logs_on_admin_id (admin_id) +# index_moderation_logs_on_moderatable (moderatable_type,moderatable_id) +# +# Foreign Keys +# +# fk_rails_... (admin_id => admins.id) +# require "test_helper" class ModerationLogTest < ActiveSupport::TestCase diff --git a/test/models/price_report_test.rb b/test/models/price_report_test.rb index 1c0526c..3fec053 100644 --- a/test/models/price_report_test.rb +++ b/test/models/price_report_test.rb @@ -1,3 +1,31 @@ +# == Schema Information +# +# Table name: price_reports +# +# id :bigint not null, primary key +# discount_price :decimal(, ) +# downvotes :integer +# price :decimal(, ) +# reported_at :datetime +# upvotes :integer +# created_at :datetime not null +# updated_at :datetime not null +# guest_id :integer not null +# product_id :integer not null +# store_id :integer not null +# +# Indexes +# +# index_price_reports_on_guest_id (guest_id) +# index_price_reports_on_product_id (product_id) +# index_price_reports_on_store_id (store_id) +# +# Foreign Keys +# +# fk_rails_... (guest_id => guests.id) +# fk_rails_... (product_id => products.id) +# fk_rails_... (store_id => stores.id) +# require "test_helper" class PriceReportTest < ActiveSupport::TestCase diff --git a/test/models/product_test.rb b/test/models/product_test.rb index 3560151..f18352f 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: products +# +# id :bigint not null, primary key +# barcode :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_products_on_barcode (barcode) UNIQUE +# require "test_helper" class ProductTest < ActiveSupport::TestCase diff --git a/test/models/store_test.rb b/test/models/store_test.rb index f7061ac..f9c88c0 100644 --- a/test/models/store_test.rb +++ b/test/models/store_test.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: stores +# +# id :bigint not null, primary key +# latitude :float +# longitude :float +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# chain_id :integer not null +# +# Indexes +# +# index_stores_on_chain_id (chain_id) +# +# Foreign Keys +# +# fk_rails_... (chain_id => chains.id) +# require "test_helper" class StoreTest < ActiveSupport::TestCase