Skip to content

Commit

Permalink
chore: annotate models
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Feb 13, 2024
1 parent 1fceef7 commit 6214892
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 72 deletions.
33 changes: 17 additions & 16 deletions app/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@
# Table name: servers
#
# id :integer not null, primary key
# organization_id :integer
# uuid :string(255)
# name :string(255)
# mode :string(255)
# ip_pool_id :integer
# created_at :datetime
# updated_at :datetime
# permalink :string(255)
# send_limit :integer
# allow_sender :boolean default(FALSE)
# deleted_at :datetime
# domains_not_to_click_track :text(65535)
# log_smtp_data :boolean default(FALSE)
# message_retention_days :integer
# mode :string(255)
# name :string(255)
# outbound_spam_threshold :decimal(8, 2)
# permalink :string(255)
# postmaster_address :string(255)
# privacy_mode :boolean default(FALSE)
# raw_message_retention_days :integer
# raw_message_retention_size :integer
# allow_sender :boolean default(FALSE)
# token :string(255)
# send_limit :integer
# send_limit_approaching_at :datetime
# send_limit_approaching_notified_at :datetime
# send_limit_exceeded_at :datetime
# send_limit_exceeded_notified_at :datetime
# spam_threshold :decimal(8, 2)
# spam_failure_threshold :decimal(8, 2)
# postmaster_address :string(255)
# spam_threshold :decimal(8, 2)
# suspended_at :datetime
# outbound_spam_threshold :decimal(8, 2)
# domains_not_to_click_track :text(65535)
# suspension_reason :string(255)
# log_smtp_data :boolean default(FALSE)
# token :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
# ip_pool_id :integer
# organization_id :integer
#
# Indexes
#
Expand Down
6 changes: 3 additions & 3 deletions app/models/statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# Table name: statistics
#
# id :integer not null, primary key
# total_messages :bigint(8) default(0)
# total_outgoing :bigint(8) default(0)
# total_incoming :bigint(8) default(0)
# total_incoming :bigint default(0)
# total_messages :bigint default(0)
# total_outgoing :bigint default(0)
#

class Statistic < ApplicationRecord
Expand Down
83 changes: 46 additions & 37 deletions lib/tasks/auto_annotate_models.rake
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
# frozen_string_literal: true

# 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(
"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" => "true",
"show_indexes" => "true",
"simple_indexes" => "false",
"model_dir" => "app/models",
"root_dir" => "",
"include_version" => "false",
"require" => "",
"exclude_tests" => "false",
"exclude_fixtures" => "false",
"exclude_factories" => "false",
"exclude_serializers" => "false",
"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
'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' => 'true',
'simple_indexes' => 'false',
'model_dir' => 'app/models',
'root_dir' => '',
'include_version' => 'false',
'require' => '',
'exclude_tests' => 'false',
'exclude_fixtures' => 'false',
'exclude_factories' => 'false',
'exclude_serializers' => 'false',
'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

Expand Down
16 changes: 16 additions & 0 deletions spec/factories/credential_factory.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: credentials
#
# id :integer not null, primary key
# hold :boolean default(FALSE)
# key :string(255)
# last_used_at :datetime
# name :string(255)
# options :text(65535)
# type :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
# server_id :integer
#
FactoryBot.define do
factory :credential do
server
Expand Down
20 changes: 20 additions & 0 deletions spec/factories/http_endpoint_factory.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: http_endpoints
#
# id :integer not null, primary key
# disabled_until :datetime
# encoding :string(255)
# error :text(65535)
# format :string(255)
# include_attachments :boolean default(TRUE)
# last_used_at :datetime
# name :string(255)
# strip_replies :boolean default(FALSE)
# timeout :integer
# url :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
# server_id :integer
#
FactoryBot.define do
factory :http_endpoint do
server
Expand Down
21 changes: 21 additions & 0 deletions spec/factories/route_factory.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: routes
#
# id :integer not null, primary key
# endpoint_type :string(255)
# mode :string(255)
# name :string(255)
# spam_mode :string(255)
# token :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
# domain_id :integer
# endpoint_id :integer
# server_id :integer
#
# Indexes
#
# index_routes_on_token (token)
#
FactoryBot.define do
factory :route do
name { "test" }
Expand Down
33 changes: 17 additions & 16 deletions spec/factories/server_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@
# Table name: servers
#
# id :integer not null, primary key
# organization_id :integer
# uuid :string(255)
# name :string(255)
# mode :string(255)
# ip_pool_id :integer
# created_at :datetime
# updated_at :datetime
# permalink :string(255)
# send_limit :integer
# allow_sender :boolean default(FALSE)
# deleted_at :datetime
# domains_not_to_click_track :text(65535)
# log_smtp_data :boolean default(FALSE)
# message_retention_days :integer
# mode :string(255)
# name :string(255)
# outbound_spam_threshold :decimal(8, 2)
# permalink :string(255)
# postmaster_address :string(255)
# privacy_mode :boolean default(FALSE)
# raw_message_retention_days :integer
# raw_message_retention_size :integer
# allow_sender :boolean default(FALSE)
# token :string(255)
# send_limit :integer
# send_limit_approaching_at :datetime
# send_limit_approaching_notified_at :datetime
# send_limit_exceeded_at :datetime
# send_limit_exceeded_notified_at :datetime
# spam_threshold :decimal(8, 2)
# spam_failure_threshold :decimal(8, 2)
# postmaster_address :string(255)
# spam_threshold :decimal(8, 2)
# suspended_at :datetime
# outbound_spam_threshold :decimal(8, 2)
# domains_not_to_click_track :text(65535)
# suspension_reason :string(255)
# log_smtp_data :boolean default(FALSE)
# token :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
# ip_pool_id :integer
# organization_id :integer
#
# Indexes
#
Expand Down

0 comments on commit 6214892

Please sign in to comment.