0
0

annotate models (#2697)

* add annotate to Gemfile

* rails g annotate:install

* configure annotate_models

* add schema info to models

* fix rubocop to add frozen_string_literal
This commit is contained in:
yhirano 2017-05-02 09:14:47 +09:00 committed by Eugen Rochko
parent a4859446ab
commit 298796cc7b
23 changed files with 355 additions and 1 deletions

View File

@ -90,6 +90,7 @@ group :development do
gem 'letter_opener_web'
gem 'bullet'
gem 'active_record_query_trace'
gem 'annotate'
gem 'capistrano', '3.8.0'
gem 'capistrano-rails'

View File

@ -43,6 +43,9 @@ GEM
public_suffix (~> 2.0, >= 2.0.2)
airbrussh (1.2.0)
sshkit (>= 1.6.1, != 1.7.0)
annotate (2.7.1)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
arel (7.1.4)
ast (2.3.0)
attr_encrypted (3.0.3)
@ -345,7 +348,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rake (12.0.0)
rake (11.3.0)
react-rails (1.11.0)
babel-transpiler (>= 0.7.0)
connection_pool
@ -483,6 +486,7 @@ PLATFORMS
DEPENDENCIES
active_record_query_trace
addressable
annotate
autoprefixer-rails
aws-sdk (>= 2.0)
best_in_place (~> 3.0.1)

View File

@ -1,4 +1,42 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: accounts
#
# id :integer not null, primary key
# username :string default(""), not null
# domain :string
# secret :string default(""), not null
# private_key :text
# public_key :text default(""), not null
# remote_url :string default(""), not null
# salmon_url :string default(""), not null
# hub_url :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
# note :text default(""), not null
# display_name :string default(""), not null
# uri :string default(""), not null
# url :string
# avatar_file_name :string
# avatar_content_type :string
# avatar_file_size :integer
# avatar_updated_at :datetime
# header_file_name :string
# header_content_type :string
# header_file_size :integer
# header_updated_at :datetime
# avatar_remote_url :string
# subscription_expires_at :datetime
# silenced :boolean default(FALSE), not null
# suspended :boolean default(FALSE), not null
# locked :boolean default(FALSE), not null
# header_remote_url :string default(""), not null
# statuses_count :integer default(0), not null
# followers_count :integer default(0), not null
# following_count :integer default(0), not null
# last_webfingered_at :datetime
#
class Account < ApplicationRecord
include Targetable

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: blocks
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Block < ApplicationRecord
include Paginable

View File

@ -1,4 +1,15 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: domain_blocks
#
# id :integer not null, primary key
# domain :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
# severity :integer default("silence")
# reject_media :boolean
#
class DomainBlock < ApplicationRecord
enum severity: [:silence, :suspend]

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: favourites
#
# id :integer not null, primary key
# account_id :integer not null
# status_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Favourite < ApplicationRecord
include Paginable

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follows
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Follow < ApplicationRecord
include Paginable

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_requests
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class FollowRequest < ApplicationRecord
include Paginable

View File

@ -1,4 +1,19 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: imports
#
# id :integer not null, primary key
# account_id :integer not null
# type :integer not null
# approved :boolean
# created_at :datetime not null
# updated_at :datetime not null
# data_file_name :string
# data_content_type :string
# data_file_size :integer
# data_updated_at :datetime
#
class Import < ApplicationRecord
FILE_TYPES = ['text/plain', 'text/csv'].freeze

View File

@ -1,4 +1,22 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: media_attachments
#
# id :integer not null, primary key
# status_id :integer
# file_file_name :string
# file_content_type :string
# file_file_size :integer
# file_updated_at :datetime
# remote_url :string default(""), not null
# account_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# shortcode :string
# type :integer default("image"), not null
# file_meta :json
#
class MediaAttachment < ApplicationRecord
self.inheritance_column = nil

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mentions
#
# id :integer not null, primary key
# account_id :integer
# status_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Mention < ApplicationRecord
belongs_to :account, inverse_of: :mentions, required: true

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mutes
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Mute < ApplicationRecord
include Paginable

View File

@ -1,4 +1,16 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: notifications
#
# id :integer not null, primary key
# account_id :integer
# activity_id :integer
# activity_type :string
# created_at :datetime not null
# updated_at :datetime not null
# from_account_id :integer
#
class Notification < ApplicationRecord
include Paginable

View File

@ -1,4 +1,28 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: preview_cards
#
# id :integer not null, primary key
# status_id :integer
# url :string default(""), not null
# title :string
# description :string
# image_file_name :string
# image_content_type :string
# image_file_size :integer
# image_updated_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# type :integer default("link"), not null
# html :text default(""), not null
# author_name :string default(""), not null
# author_url :string default(""), not null
# provider_name :string default(""), not null
# provider_url :string default(""), not null
# width :integer default(0), not null
# height :integer default(0), not null
#
class PreviewCard < ApplicationRecord
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze

View File

@ -1,4 +1,18 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: reports
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# status_ids :integer default([]), not null, is an Array
# comment :text default(""), not null
# action_taken :boolean default(FALSE), not null
# created_at :datetime not null
# updated_at :datetime not null
# action_taken_by_account_id :integer
#
class Report < ApplicationRecord
belongs_to :account

View File

@ -1,4 +1,16 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: settings
#
# id :integer not null, primary key
# var :string not null
# value :text
# thing_type :string
# thing_id :integer
# created_at :datetime
# updated_at :datetime
#
class Setting < RailsSettings::Base
source Rails.root.join('config/settings.yml')

View File

@ -1,4 +1,27 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: statuses
#
# id :integer not null, primary key
# uri :string
# account_id :integer not null
# text :text default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
# in_reply_to_id :integer
# reblog_of_id :integer
# url :string
# sensitive :boolean default(FALSE)
# visibility :integer default("public"), not null
# in_reply_to_account_id :integer
# application_id :integer
# spoiler_text :text default(""), not null
# reply :boolean default(FALSE)
# favourites_count :integer default(0), not null
# reblogs_count :integer default(0), not null
# language :string default("en"), not null
#
class Status < ApplicationRecord
include Paginable

View File

@ -1,4 +1,16 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: stream_entries
#
# id :integer not null, primary key
# account_id :integer
# activity_id :integer
# activity_type :string
# created_at :datetime not null
# updated_at :datetime not null
# hidden :boolean default(FALSE), not null
#
class StreamEntry < ApplicationRecord
include Paginable

View File

@ -1,4 +1,18 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: subscriptions
#
# id :integer not null, primary key
# callback_url :string default(""), not null
# secret :string
# expires_at :datetime
# confirmed :boolean default(FALSE), not null
# account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# last_successful_delivery_at :datetime
#
class Subscription < ApplicationRecord
MIN_EXPIRATION = 3600 * 24 * 7

View File

@ -1,4 +1,13 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# name :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Tag < ApplicationRecord
has_and_belongs_to_many :statuses

View File

@ -1,4 +1,37 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string default(""), not null
# account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :inet
# last_sign_in_ip :inet
# admin :boolean default(FALSE)
# confirmation_token :string
# confirmed_at :datetime
# confirmation_sent_at :datetime
# unconfirmed_email :string
# locale :string
# encrypted_otp_secret :string
# encrypted_otp_secret_iv :string
# encrypted_otp_secret_salt :string
# consumed_timestep :integer
# otp_required_for_login :boolean
# last_emailed_at :datetime
# otp_backup_codes :string is an Array
# allowed_languages :string default([]), not null, is an Array
#
class User < ApplicationRecord
include Settings::Extend

View File

@ -1,4 +1,14 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: web_settings
#
# id :integer not null, primary key
# user_id :integer
# data :json
# created_at :datetime not null
# updated_at :datetime not null
#
class Web::Setting < ApplicationRecord
belongs_to :user

View File

@ -0,0 +1,44 @@
# frozen_string_literal: true
if Rails.env.development?
task :set_annotation_options do
Annotate.set_defaults(
'routes' => 'false',
'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' => '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',
'ignore_model_sub_dir' => 'false',
'ignore_columns' => nil,
'ignore_routes' => nil,
'ignore_unknown_models' => 'false',
'hide_limit_column_types' => 'integer,boolean',
'skip_on_db_migrate' => 'false',
'format_bare' => 'true',
'format_rdoc' => 'false',
'format_markdown' => 'false',
'sort' => 'false',
'force' => 'false',
'trace' => 'false',
'wrapper_open' => nil,
'wrapper_close' => nil
)
end
Annotate.load_tasks
end