mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 18:47:51 +00:00
Annotations (#327)
* Add annotate gem to the project * Annotate models, fixtures, factories and model_specs * Keep annotations only in Models * Remove unwanted changes in model specs * Exclude auto_annotate_models from rubocop
This commit is contained in:
committed by
Sojan Jose
parent
60e96f446e
commit
c08074b981
@@ -29,3 +29,4 @@ AllCops:
|
|||||||
- public/**/*
|
- public/**/*
|
||||||
- vendor/**/*
|
- vendor/**/*
|
||||||
- node_modules/**/*
|
- node_modules/**/*
|
||||||
|
- lib/tasks/auto_annotate_models.rake
|
||||||
|
|||||||
1
Gemfile
1
Gemfile
@@ -71,6 +71,7 @@ gem 'sidekiq'
|
|||||||
gem 'uglifier'
|
gem 'uglifier'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
gem 'annotate'
|
||||||
gem 'bullet'
|
gem 'bullet'
|
||||||
gem 'letter_opener'
|
gem 'letter_opener'
|
||||||
gem 'web-console'
|
gem 'web-console'
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ GEM
|
|||||||
activerecord (>= 5.0, < 6.1)
|
activerecord (>= 5.0, < 6.1)
|
||||||
addressable (2.7.0)
|
addressable (2.7.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
|
annotate (3.0.3)
|
||||||
|
activerecord (>= 3.2, < 7.0)
|
||||||
|
rake (>= 10.4, < 14.0)
|
||||||
ast (2.4.0)
|
ast (2.4.0)
|
||||||
attr_extras (6.2.1)
|
attr_extras (6.2.1)
|
||||||
aws-eventstream (1.0.3)
|
aws-eventstream (1.0.3)
|
||||||
@@ -431,6 +434,7 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
action-cable-testing
|
action-cable-testing
|
||||||
acts-as-taggable-on
|
acts-as-taggable-on
|
||||||
|
annotate
|
||||||
attr_extras
|
attr_extras
|
||||||
bootsnap
|
bootsnap
|
||||||
brakeman
|
brakeman
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: accounts
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# name :string
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
|
||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
include Events::Types
|
include Events::Types
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: attachments
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# coordinates_lat :float default(0.0)
|
||||||
|
# coordinates_long :float default(0.0)
|
||||||
|
# extension :string
|
||||||
|
# external_url :string
|
||||||
|
# fallback_title :string
|
||||||
|
# file :string
|
||||||
|
# file_type :integer default("image")
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
# message_id :integer not null
|
||||||
|
#
|
||||||
|
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
class Attachment < ApplicationRecord
|
class Attachment < ApplicationRecord
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: canned_responses
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# content :text
|
||||||
|
# short_code :string
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
#
|
||||||
|
|
||||||
class CannedResponse < ApplicationRecord
|
class CannedResponse < ApplicationRecord
|
||||||
validates_presence_of :content
|
validates_presence_of :content
|
||||||
validates_presence_of :short_code
|
validates_presence_of :short_code
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: channel_facebook_pages
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# avatar :string
|
||||||
|
# name :string not null
|
||||||
|
# page_access_token :string not null
|
||||||
|
# user_access_token :string not null
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
# page_id :string not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_channel_facebook_pages_on_page_id (page_id)
|
||||||
|
#
|
||||||
|
|
||||||
module Channel
|
module Channel
|
||||||
class FacebookPage < ApplicationRecord
|
class FacebookPage < ApplicationRecord
|
||||||
self.table_name = 'channel_facebook_pages'
|
self.table_name = 'channel_facebook_pages'
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: channel_web_widgets
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# website_name :string
|
||||||
|
# website_token :string
|
||||||
|
# website_url :string
|
||||||
|
# widget_color :string default("#1f93ff")
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_channel_web_widgets_on_website_token (website_token) UNIQUE
|
||||||
|
#
|
||||||
|
|
||||||
module Channel
|
module Channel
|
||||||
class WebWidget < ApplicationRecord
|
class WebWidget < ApplicationRecord
|
||||||
self.table_name = 'channel_web_widgets'
|
self.table_name = 'channel_web_widgets'
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: contacts
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# avatar :string
|
||||||
|
# email :string
|
||||||
|
# name :string
|
||||||
|
# phone_number :string
|
||||||
|
# pubsub_token :string
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_contacts_on_account_id (account_id)
|
||||||
|
# index_contacts_on_pubsub_token (pubsub_token) UNIQUE
|
||||||
|
#
|
||||||
|
|
||||||
class Contact < ApplicationRecord
|
class Contact < ApplicationRecord
|
||||||
include Pubsubable
|
include Pubsubable
|
||||||
validates :account_id, presence: true
|
validates :account_id, presence: true
|
||||||
|
|||||||
@@ -1,3 +1,27 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: contact_inboxes
|
||||||
|
#
|
||||||
|
# id :bigint not null, primary key
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# contact_id :bigint
|
||||||
|
# inbox_id :bigint
|
||||||
|
# source_id :string not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_contact_inboxes_on_contact_id (contact_id)
|
||||||
|
# index_contact_inboxes_on_inbox_id (inbox_id)
|
||||||
|
# index_contact_inboxes_on_inbox_id_and_source_id (inbox_id,source_id) UNIQUE
|
||||||
|
# index_contact_inboxes_on_source_id (source_id)
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (contact_id => contacts.id)
|
||||||
|
# fk_rails_... (inbox_id => inboxes.id)
|
||||||
|
#
|
||||||
|
|
||||||
class ContactInbox < ApplicationRecord
|
class ContactInbox < ApplicationRecord
|
||||||
validates :inbox_id, presence: true
|
validates :inbox_id, presence: true
|
||||||
validates :contact_id, presence: true
|
validates :contact_id, presence: true
|
||||||
|
|||||||
@@ -1,3 +1,27 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: conversations
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# additional_attributes :jsonb
|
||||||
|
# agent_last_seen_at :datetime
|
||||||
|
# locked :boolean default(FALSE)
|
||||||
|
# status :integer default("open"), not null
|
||||||
|
# user_last_seen_at :datetime
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
# assignee_id :integer
|
||||||
|
# contact_id :bigint
|
||||||
|
# display_id :integer not null
|
||||||
|
# inbox_id :integer not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_conversations_on_account_id (account_id)
|
||||||
|
# index_conversations_on_account_id_and_display_id (account_id,display_id) UNIQUE
|
||||||
|
#
|
||||||
|
|
||||||
class Conversation < ApplicationRecord
|
class Conversation < ApplicationRecord
|
||||||
include Events::Types
|
include Events::Types
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: inboxes
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# channel_type :string
|
||||||
|
# name :string not null
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
# channel_id :integer not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_inboxes_on_account_id (account_id)
|
||||||
|
#
|
||||||
|
|
||||||
class Inbox < ApplicationRecord
|
class Inbox < ApplicationRecord
|
||||||
validates :account_id, presence: true
|
validates :account_id, presence: true
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: inbox_members
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# inbox_id :integer not null
|
||||||
|
# user_id :integer not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_inbox_members_on_inbox_id (inbox_id)
|
||||||
|
#
|
||||||
|
|
||||||
class InboxMember < ApplicationRecord
|
class InboxMember < ApplicationRecord
|
||||||
validates :inbox_id, presence: true
|
validates :inbox_id, presence: true
|
||||||
validates :user_id, presence: true
|
validates :user_id, presence: true
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: messages
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# content :text
|
||||||
|
# message_type :integer not null
|
||||||
|
# private :boolean default(FALSE)
|
||||||
|
# status :integer default("sent")
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
# conversation_id :integer not null
|
||||||
|
# fb_id :string
|
||||||
|
# inbox_id :integer not null
|
||||||
|
# user_id :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_messages_on_conversation_id (conversation_id)
|
||||||
|
#
|
||||||
|
|
||||||
class Message < ApplicationRecord
|
class Message < ApplicationRecord
|
||||||
include Events::Types
|
include Events::Types
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: subscriptions
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# billing_plan :string default("trial")
|
||||||
|
# expiry :datetime
|
||||||
|
# payment_source_added :boolean default(FALSE)
|
||||||
|
# pricing_version :string
|
||||||
|
# state :integer default("trial")
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer
|
||||||
|
# stripe_customer_id :string
|
||||||
|
#
|
||||||
|
|
||||||
class Subscription < ApplicationRecord
|
class Subscription < ApplicationRecord
|
||||||
include Events::Types
|
include Events::Types
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: telegram_bots
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# auth_key :string
|
||||||
|
# name :string
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer
|
||||||
|
#
|
||||||
|
|
||||||
class TelegramBot < ApplicationRecord
|
class TelegramBot < ApplicationRecord
|
||||||
belongs_to :account
|
belongs_to :account
|
||||||
has_one :inbox, as: :channel, dependent: :destroy
|
has_one :inbox, as: :channel, dependent: :destroy
|
||||||
|
|||||||
@@ -1,3 +1,48 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: users
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# confirmation_sent_at :datetime
|
||||||
|
# confirmation_token :string
|
||||||
|
# confirmed_at :datetime
|
||||||
|
# current_sign_in_at :datetime
|
||||||
|
# current_sign_in_ip :string
|
||||||
|
# email :string
|
||||||
|
# encrypted_password :string default(""), not null
|
||||||
|
# image :string
|
||||||
|
# last_sign_in_at :datetime
|
||||||
|
# last_sign_in_ip :string
|
||||||
|
# name :string not null
|
||||||
|
# nickname :string
|
||||||
|
# provider :string default("email"), not null
|
||||||
|
# pubsub_token :string
|
||||||
|
# remember_created_at :datetime
|
||||||
|
# reset_password_sent_at :datetime
|
||||||
|
# reset_password_token :string
|
||||||
|
# role :integer default("agent")
|
||||||
|
# sign_in_count :integer default(0), not null
|
||||||
|
# tokens :json
|
||||||
|
# uid :string default(""), not null
|
||||||
|
# unconfirmed_email :string
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# account_id :integer not null
|
||||||
|
# inviter_id :bigint
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_users_on_email (email)
|
||||||
|
# index_users_on_inviter_id (inviter_id)
|
||||||
|
# index_users_on_pubsub_token (pubsub_token) UNIQUE
|
||||||
|
# index_users_on_reset_password_token (reset_password_token) UNIQUE
|
||||||
|
# index_users_on_uid_and_provider (uid,provider) UNIQUE
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (inviter_id => users.id) ON DELETE => nullify
|
||||||
|
#
|
||||||
|
|
||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
# Include default devise modules.
|
# Include default devise modules.
|
||||||
include DeviseTokenAuth::Concerns::User
|
include DeviseTokenAuth::Concerns::User
|
||||||
|
|||||||
57
lib/tasks/auto_annotate_models.rake
Normal file
57
lib/tasks/auto_annotate_models.rake
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# NOTE: only doing this in development as some production environments (Heroku)
|
||||||
|
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
||||||
|
# NOTE: to have a dev-mode tool do its thing in production.
|
||||||
|
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(
|
||||||
|
'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' => 'true',
|
||||||
|
'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_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
|
||||||
Reference in New Issue
Block a user