rubocop: fix various style issues.
This commit is contained in:
@@ -10,7 +10,7 @@ class CreateUserNameChangeRequests < ActiveRecord::Migration[4.2]
|
||||
t.text :rejection_reason
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
add_index :user_name_change_requests, :user_id
|
||||
add_index :user_name_change_requests, :original_name
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class CreateKeyValues < ActiveRecord::Migration[4.2]
|
||||
t.text :value
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
add_index :key_values, :key, :unique => true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class AddPixivIdToPosts < ActiveRecord::Migration[4.2]
|
||||
execute "drop index index_posts_on_pixiv_id"
|
||||
execute "create index index_posts_on_pixiv_id on posts (pixiv_id) where pixiv_id is not null"
|
||||
end
|
||||
|
||||
|
||||
def down
|
||||
execute "set statement_timeout = 0"
|
||||
remove_column :posts, :pixiv_id
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class ChangeTagSubscriptionTagQueryDelimiter < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
#TagSubscription.find_each do |tag_subscription|
|
||||
# TagSubscription.find_each do |tag_subscription|
|
||||
# tag_subscription.update_column(:tag_query, tag_subscription.tag_query.scan(/\S+/).join("\n"))
|
||||
#end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class RemoveUnusedIndexes < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
#remove_index :posts, :source
|
||||
# remove_index :posts, :source
|
||||
remove_index :posts, :uploader_ip_addr
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddMinLevelToForumTopics < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :forum_topics, :min_level, :integer, :default => 0, :null => false
|
||||
add_column :forum_topics, :min_level, :integer, :default => 0, :null => false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class CreatePostApprovals < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :post_approvals do |t|
|
||||
t.integer :user_id, null: false
|
||||
t.integer :post_id, null: false
|
||||
t.integer :user_id, null: false
|
||||
t.integer :post_id, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class DropTransactionLogItems < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
drop_table :transaction_log_items
|
||||
drop_table :transaction_log_items
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class DropPoolVersions < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
drop_table :pool_versions
|
||||
drop_table :pool_versions
|
||||
end
|
||||
|
||||
def down
|
||||
raise NotImplementedError
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class CreateTokenBuckets < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
execute "create unlogged table token_buckets (user_id integer, last_touched_at timestamp not null, token_count real not null)"
|
||||
add_index :token_buckets, :user_id, :unique => true
|
||||
execute "create unlogged table token_buckets (user_id integer, last_touched_at timestamp not null, token_count real not null)"
|
||||
add_index :token_buckets, :user_id, :unique => true
|
||||
end
|
||||
|
||||
def down
|
||||
raise NotImplementedError
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class AddTrigramIndexToUsers < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
execute "set statement_timeout = 0"
|
||||
execute "create index index_users_on_name_trgm on users using gin (lower(name) gin_trgm_ops)"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class AddTagsToSavedSearches < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
add_column :saved_searches, :labels, "text", array: true, null: false, default: []
|
||||
add_index :saved_searches, :labels, using: :gin
|
||||
rename_column :saved_searches, :tag_query, :query
|
||||
execute "set statement_timeout = 0"
|
||||
add_column :saved_searches, :labels, "text", array: true, null: false, default: []
|
||||
add_index :saved_searches, :labels, using: :gin
|
||||
rename_column :saved_searches, :tag_query, :query
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class DropPostVersions < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
drop_table :post_versions
|
||||
execute "set statement_timeout = 0"
|
||||
drop_table :post_versions
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class AddForumPostIdToTagRequests < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
ApplicationRecord.without_timeout do
|
||||
add_column :tag_aliases, :forum_post_id, :integer
|
||||
add_column :tag_implications, :forum_post_id, :integer
|
||||
add_column :bulk_update_requests, :forum_post_id, :integer
|
||||
end
|
||||
ApplicationRecord.without_timeout do
|
||||
add_column :tag_aliases, :forum_post_id, :integer
|
||||
add_column :tag_implications, :forum_post_id, :integer
|
||||
add_column :bulk_update_requests, :forum_post_id, :integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddTitleToBulkUpdateRequests < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :bulk_update_requests, :title, :text
|
||||
add_column :bulk_update_requests, :title, :text
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class AddUniqueNameConstraintToUsers < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
User.without_timeout do
|
||||
remove_index :users, name: "index_users_on_name"
|
||||
execute "create unique index index_users_on_name on users(lower(name))"
|
||||
end
|
||||
User.without_timeout do
|
||||
remove_index :users, name: "index_users_on_name"
|
||||
execute "create unique index index_users_on_name on users(lower(name))"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddUpdatedAtIndexToPools < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_index :pools, :updated_at
|
||||
add_index :pools, :updated_at
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class CreatePostReplacements < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :post_replacements do |t|
|
||||
t.integer :post_id, null: false
|
||||
t.integer :creator_id, null: false
|
||||
t.text :original_url, null: false
|
||||
t.text :replacement_url, null: false
|
||||
t.integer :post_id, null: false
|
||||
t.integer :creator_id, null: false
|
||||
t.text :original_url, null: false
|
||||
t.text :replacement_url, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddSortIndexesToForumTopics < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_index :forum_topics, [:is_sticky, :updated_at]
|
||||
add_index :forum_topics, [:is_sticky, :updated_at]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class FixLastNotedAtIndexOnPosts < ActiveRecord::Migration[4.2]
|
||||
|
||||
remove_index :posts, column: :last_noted_at
|
||||
add_index :posts, :last_noted_at, order: "DESC NULLS LAST"
|
||||
|
||||
|
||||
execute "analyze posts"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class AddIsSpamToDmails < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
Dmail.without_timeout do
|
||||
add_column :dmails, :is_spam, :boolean, default: false
|
||||
end
|
||||
Dmail.without_timeout do
|
||||
add_column :dmails, :is_spam, :boolean, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class AddTrigramIndexToTags < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
Tag.without_timeout do
|
||||
execute "create index index_tags_on_name_trgm on tags using gin (name gin_trgm_ops)"
|
||||
end
|
||||
Tag.without_timeout do
|
||||
execute "create index index_tags_on_name_trgm on tags using gin (name gin_trgm_ops)"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Tag.without_timeout do
|
||||
execute "drop index index_tags_on_name_trgm"
|
||||
end
|
||||
Tag.without_timeout do
|
||||
execute "drop index index_tags_on_name_trgm"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class AddTrigramIndexToArtistUrls < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
|
||||
|
||||
change_table :artist_urls do |t|
|
||||
t.remove_index column: :url, name: :index_artist_urls_on_url
|
||||
t.remove_index column: :url, name: :index_artist_urls_on_url_pattern, opclass: :text_pattern_ops
|
||||
|
||||
@@ -2,14 +2,14 @@ require 'set'
|
||||
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
Delayed::Worker.delay_jobs = false
|
||||
$used_names = Set.new([""])
|
||||
used_names = Set.new([""])
|
||||
|
||||
def rand_string(n, unique = false)
|
||||
string = ""
|
||||
|
||||
n = rand(n) + 1
|
||||
|
||||
while $used_names.include?(string)
|
||||
while used_names.include?(string)
|
||||
consonants = "bcdfghjklmnpqrstvwxz".scan(/./)
|
||||
vowels = "aeiouy".scan(/./)
|
||||
string = ""
|
||||
@@ -20,7 +20,7 @@ def rand_string(n, unique = false)
|
||||
return string unless unique
|
||||
end
|
||||
|
||||
$used_names.add(string)
|
||||
used_names.add(string)
|
||||
string
|
||||
end
|
||||
|
||||
@@ -47,36 +47,35 @@ if User.count == 0
|
||||
)
|
||||
|
||||
CurrentUser.user = user
|
||||
User::Levels.constants.reject{ |x| x == :ADMIN }.each do |level|
|
||||
User::Levels.constants.reject { |x| x == :ADMIN }.each do |level|
|
||||
newuser = User.create(
|
||||
:name => level.to_s.downcase,
|
||||
:password => "password1",
|
||||
:password_confirmation => "password1"
|
||||
name: level.to_s.downcase,
|
||||
password: "password1",
|
||||
password_confirmation: "password1"
|
||||
)
|
||||
newuser.promote_to!(User::Levels.const_get(level), {:is_upgrade => true, :skip_dmail => true})
|
||||
newuser.promote_to!(User::Levels.const_get(level), :is_upgrade => true, :skip_dmail => true)
|
||||
end
|
||||
|
||||
newuser = User.create(
|
||||
:name => "banned",
|
||||
:password => "password1",
|
||||
:password_confirmation => "password1"
|
||||
)
|
||||
)
|
||||
Ban.create(:user_id => newuser.id, :reason => "from the start", :duration => 99999)
|
||||
|
||||
newuser = User.create(
|
||||
:name => "uploader",
|
||||
:password => "password1",
|
||||
:password_confirmation => "password1"
|
||||
)
|
||||
newuser.promote_to!(User::Levels::BUILDER, {:can_upload_free => true, :is_upgrade => true, :skip_dmail => true})
|
||||
)
|
||||
newuser.promote_to!(User::Levels::BUILDER, :can_upload_free => true, :is_upgrade => true, :skip_dmail => true)
|
||||
|
||||
newuser = User.create(
|
||||
:name => "approver",
|
||||
:password => "password1",
|
||||
:password_confirmation => "password1"
|
||||
)
|
||||
newuser.promote_to!(User::Levels::BUILDER, {:can_approve_posts => true, :is_upgrade => true, :skip_dmail => true})
|
||||
|
||||
)
|
||||
newuser.promote_to!(User::Levels::BUILDER, :can_approve_posts => true, :is_upgrade => true, :skip_dmail => true)
|
||||
end
|
||||
|
||||
0.upto(10) do |i|
|
||||
@@ -86,7 +85,7 @@ if User.count == 0
|
||||
:password_confirmation => "password1"
|
||||
)
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping users"
|
||||
user = User.find_by_name("albert")
|
||||
@@ -101,7 +100,7 @@ if Upload.count == 0
|
||||
1.upto(50) do |i|
|
||||
color1 = rand(4096).to_s(16)
|
||||
color2 = rand(4096).to_s(16)
|
||||
width = rand(2000) + 100
|
||||
width = rand(100..2099)
|
||||
height = (width * (rand(0.5) + 1)).to_i
|
||||
url = "http://ipsumimage.appspot.com/#{width}x#{height},#{color1}"
|
||||
tags = rand(1_000_000_000).to_s.scan(/../).join(" ")
|
||||
@@ -144,7 +143,7 @@ if Artist.count == 0
|
||||
20.times do |i|
|
||||
Artist.create(:name => rand_string(9, true))
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping artists"
|
||||
end
|
||||
@@ -155,7 +154,7 @@ if TagAlias.count == 0
|
||||
20.times do |i|
|
||||
TagAlias.create(:antecedent_name => rand_string(9, true), :consequent_name => rand_string(9, true))
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping tag aliases"
|
||||
end
|
||||
@@ -166,7 +165,7 @@ if TagImplication.count == 0
|
||||
20.times do |i|
|
||||
TagImplication.create(:antecedent_name => rand_string(9, true), :consequent_name => rand_string(9, true))
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping tag implications"
|
||||
end
|
||||
@@ -180,7 +179,7 @@ if Pool.count == 0
|
||||
pool.add!(Post.order("random()").first)
|
||||
end
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
used_names = Set.new([""])
|
||||
end
|
||||
|
||||
if Favorite.count == 0
|
||||
|
||||
Reference in New Issue
Block a user