Skip to content

Commit

Permalink
Annotations (chatwoot#327)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mukesh4139 authored and sojan-official committed Nov 30, 2019
1 parent 60e96f4 commit c08074b
Show file tree
Hide file tree
Showing 18 changed files with 335 additions and 0 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ AllCops:
- public/**/*
- vendor/**/*
- node_modules/**/*
- lib/tasks/auto_annotate_models.rake
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ gem 'sidekiq'
gem 'uglifier'

group :development do
gem 'annotate'
gem 'bullet'
gem 'letter_opener'
gem 'web-console'
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ GEM
activerecord (>= 5.0, < 6.1)
addressable (2.7.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)
attr_extras (6.2.1)
aws-eventstream (1.0.3)
Expand Down Expand Up @@ -431,6 +434,7 @@ PLATFORMS
DEPENDENCIES
action-cable-testing
acts-as-taggable-on
annotate
attr_extras
bootsnap
brakeman
Expand Down
10 changes: 10 additions & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
@@ -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
include Events::Types

Expand Down
18 changes: 18 additions & 0 deletions app/models/attachment.rb
Original file line number Diff line number Diff line change
@@ -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 'open-uri'
class Attachment < ApplicationRecord
Expand Down
12 changes: 12 additions & 0 deletions app/models/canned_response.rb
Original file line number Diff line number Diff line change
@@ -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
validates_presence_of :content
validates_presence_of :short_code
Expand Down
19 changes: 19 additions & 0 deletions app/models/channel/facebook_page.rb
Original file line number Diff line number Diff line change
@@ -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
class FacebookPage < ApplicationRecord
self.table_name = 'channel_facebook_pages'
Expand Down
18 changes: 18 additions & 0 deletions app/models/channel/web_widget.rb
Original file line number Diff line number Diff line change
@@ -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
class WebWidget < ApplicationRecord
self.table_name = 'channel_web_widgets'
Expand Down
20 changes: 20 additions & 0 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
@@ -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
include Pubsubable
validates :account_id, presence: true
Expand Down
24 changes: 24 additions & 0 deletions app/models/contact_inbox.rb
Original file line number Diff line number Diff line change
@@ -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
validates :inbox_id, presence: true
validates :contact_id, presence: true
Expand Down
24 changes: 24 additions & 0 deletions app/models/conversation.rb
Original file line number Diff line number Diff line change
@@ -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
include Events::Types

Expand Down
17 changes: 17 additions & 0 deletions app/models/inbox.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# 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
validates :account_id, presence: true

Expand Down
15 changes: 15 additions & 0 deletions app/models/inbox_member.rb
Original file line number Diff line number Diff line change
@@ -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
validates :inbox_id, presence: true
validates :user_id, presence: true
Expand Down
22 changes: 22 additions & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
@@ -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
include Events::Types

Expand Down
16 changes: 16 additions & 0 deletions app/models/subscription.rb
Original file line number Diff line number Diff line change
@@ -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
include Events::Types

Expand Down
12 changes: 12 additions & 0 deletions app/models/telegram_bot.rb
Original file line number Diff line number Diff line change
@@ -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
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
Expand Down
45 changes: 45 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -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
# Include default devise modules.
include DeviseTokenAuth::Concerns::User
Expand Down
Loading

0 comments on commit c08074b

Please sign in to comment.