Merge remote-tracking branch 'tootsuite/main' into custom/quote
# Conflicts: # app/services/fetch_link_card_service.rb
This commit is contained in:
@@ -17,6 +17,21 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
|
||||
belongs_to :account, inverse_of: :stream_entries
|
||||
end
|
||||
|
||||
class Status < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account
|
||||
end
|
||||
|
||||
class Mention < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account
|
||||
end
|
||||
|
||||
class StatusPin < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account
|
||||
end
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
|
||||
@@ -1,6 +1,46 @@
|
||||
class RemoveFauxRemoteAccountDuplicates < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
class StreamEntry < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account, inverse_of: :stream_entries
|
||||
end
|
||||
|
||||
class Status < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account, inverse_of: :statuses
|
||||
has_many :favourites, inverse_of: :status, dependent: :destroy
|
||||
has_many :mentions, dependent: :destroy, inverse_of: :status
|
||||
end
|
||||
|
||||
class Favourite < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account, inverse_of: :favourites
|
||||
belongs_to :status, inverse_of: :favourites
|
||||
end
|
||||
|
||||
class Mention < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account, inverse_of: :mentions
|
||||
belongs_to :status
|
||||
end
|
||||
|
||||
class Notification < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account, optional: true
|
||||
belongs_to :from_account, class_name: 'Account', optional: true
|
||||
belongs_to :activity, polymorphic: true, optional: true
|
||||
end
|
||||
|
||||
class Account < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
has_many :stream_entries, inverse_of: :account, dependent: :destroy
|
||||
has_many :statuses, inverse_of: :account, dependent: :destroy
|
||||
has_many :favourites, inverse_of: :account, dependent: :destroy
|
||||
has_many :mentions, inverse_of: :account, dependent: :destroy
|
||||
has_many :notifications, inverse_of: :account, dependent: :destroy
|
||||
end
|
||||
|
||||
def up
|
||||
local_domain = Rails.configuration.x.local_domain
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
class AddInstanceActor < ActiveRecord::Migration[5.2]
|
||||
class Account < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
validates :username, uniqueness: { scope: :domain, case_sensitive: false }
|
||||
end
|
||||
|
||||
def up
|
||||
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
class UpdatePtLocales < ActiveRecord::Migration[5.2]
|
||||
class User < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
end
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
|
||||
5
db/migrate/20210616214526_create_user_ips.rb
Normal file
5
db/migrate/20210616214526_create_user_ips.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class CreateUserIps < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_view :user_ips
|
||||
end
|
||||
end
|
||||
5
db/migrate/20210904215403_add_edited_at_to_statuses.rb
Normal file
5
db/migrate/20210904215403_add_edited_at_to_statuses.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddEditedAtToStatuses < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :statuses, :edited_at, :datetime
|
||||
end
|
||||
end
|
||||
13
db/migrate/20210908220918_create_status_edits.rb
Normal file
13
db/migrate/20210908220918_create_status_edits.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateStatusEdits < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :status_edits do |t|
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :account, null: true, foreign_key: { on_delete: :nullify }
|
||||
t.text :text, null: false, default: ''
|
||||
t.text :spoiler_text, null: false, default: ''
|
||||
t.boolean :media_attachments_changed, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
12
db/migrate/20211031031021_create_preview_card_providers.rb
Normal file
12
db/migrate/20211031031021_create_preview_card_providers.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreatePreviewCardProviders < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :preview_card_providers do |t|
|
||||
t.string :domain, null: false, default: '', index: { unique: true }
|
||||
t.attachment :icon
|
||||
t.boolean :trendable
|
||||
t.datetime :reviewed_at
|
||||
t.datetime :requested_review_at
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddLanguageToPreviewCards < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :preview_cards, :language, :string
|
||||
add_column :preview_cards, :max_score, :float
|
||||
add_column :preview_cards, :max_score_at, :datetime
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddTrendableToPreviewCards < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :preview_cards, :trendable, :boolean
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddLinkTypeToPreviewCards < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :preview_cards, :link_type, :int
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,24 @@
|
||||
class UpdateAccountSummariesToVersion2 < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
reapplication_follow_recommendations_v2 do
|
||||
drop_view :account_summaries, materialized: true
|
||||
create_view :account_summaries, version: 2, materialized: { no_data: true }
|
||||
safety_assured { add_index :account_summaries, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
reapplication_follow_recommendations_v2 do
|
||||
drop_view :account_summaries, materialized: true
|
||||
create_view :account_summaries, version: 1, materialized: { no_data: true }
|
||||
safety_assured { add_index :account_summaries, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
|
||||
def reapplication_follow_recommendations_v2
|
||||
drop_view :follow_recommendations, materialized: true
|
||||
yield
|
||||
create_view :follow_recommendations, version: 2, materialized: { no_data: true }
|
||||
safety_assured { add_index :follow_recommendations, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
21
db/migrate/20211231080958_add_category_to_reports.rb
Normal file
21
db/migrate/20211231080958_add_category_to_reports.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddCategoryToReports < ActiveRecord::Migration[6.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured { add_column_with_default :reports, :category, :int, default: 0, allow_null: false }
|
||||
add_column :reports, :action_taken_at, :datetime
|
||||
add_column :reports, :rule_ids, :bigint, array: true
|
||||
safety_assured { execute 'UPDATE reports SET action_taken_at = updated_at WHERE action_taken = TRUE' }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { execute 'UPDATE reports SET action_taken = TRUE WHERE action_taken_at IS NOT NULL' }
|
||||
remove_column :reports, :category
|
||||
remove_column :reports, :action_taken_at
|
||||
remove_column :reports, :rule_ids
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class RemoveMentionsStatusIdIndex < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
remove_index :mentions, name: :mentions_status_id_index if index_exists?(:mentions, :status_id, name: :mentions_status_id_index)
|
||||
end
|
||||
|
||||
def down
|
||||
# As this index should not exist and is a duplicate of another index, do not re-create it
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddReportIdToAccountWarnings < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured { add_reference :account_warnings, :report, foreign_key: { on_delete: :cascade }, index: false }
|
||||
add_column :account_warnings, :status_ids, :string, array: true
|
||||
end
|
||||
end
|
||||
21
db/migrate/20220115125341_fix_account_warning_actions.rb
Normal file
21
db/migrate/20220115125341_fix_account_warning_actions.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class FixAccountWarningActions < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
execute 'UPDATE account_warnings SET action = 1000 WHERE action = 1'
|
||||
execute 'UPDATE account_warnings SET action = 2000 WHERE action = 2'
|
||||
execute 'UPDATE account_warnings SET action = 3000 WHERE action = 3'
|
||||
execute 'UPDATE account_warnings SET action = 4000 WHERE action = 4'
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
execute 'UPDATE account_warnings SET action = 1 WHERE action = 1000'
|
||||
execute 'UPDATE account_warnings SET action = 2 WHERE action = 2000'
|
||||
execute 'UPDATE account_warnings SET action = 3 WHERE action = 3000'
|
||||
execute 'UPDATE account_warnings SET action = 4 WHERE action = 4000'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddDeletedAtIndexOnStatuses < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :statuses, :deleted_at, where: 'deleted_at IS NOT NULL', algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveCurrentSignInIpFromUsers < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
remove_column :users, :current_sign_in_ip, :inet
|
||||
remove_column :users, :last_sign_in_ip, :inet
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropAccountIdentityProofs < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
drop_table :account_identity_proofs
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveActionTakenFromReports < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured { remove_column :reports, :action_taken, :boolean, default: false, null: false }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveIndexUsersOnRememberToken < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
remove_index :users, name: :index_users_on_remember_token
|
||||
end
|
||||
|
||||
def down
|
||||
add_index :users, :remember_token, algorithm: :concurrently, unique: true, name: :index_users_on_remember_token
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class RemoveRememberableFromUsers < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
remove_column :users, :remember_token, :string, null: true, default: nil
|
||||
remove_column :users, :remember_created_at, :datetime, null: true, default: nil
|
||||
end
|
||||
end
|
||||
end
|
||||
86
db/schema.rb
86
db/schema.rb
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
ActiveRecord::Schema.define(version: 2022_01_18_183123) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -51,18 +51,6 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
|
||||
end
|
||||
|
||||
create_table "account_identity_proofs", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.string "provider", default: "", null: false
|
||||
t.string "provider_username", default: "", null: false
|
||||
t.text "token", default: "", null: false
|
||||
t.boolean "verified", default: false, null: false
|
||||
t.boolean "live", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id", "provider", "provider_username"], name: "index_account_proofs_on_account_and_provider_and_username", unique: true
|
||||
end
|
||||
|
||||
create_table "account_migrations", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.string "acct", default: "", null: false
|
||||
@@ -145,6 +133,8 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.text "text", default: "", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "report_id"
|
||||
t.string "status_ids", array: true
|
||||
t.index ["account_id"], name: "index_account_warnings_on_account_id"
|
||||
t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
|
||||
end
|
||||
@@ -689,6 +679,20 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.index ["status_id"], name: "index_polls_on_status_id"
|
||||
end
|
||||
|
||||
create_table "preview_card_providers", force: :cascade do |t|
|
||||
t.string "domain", default: "", null: false
|
||||
t.string "icon_file_name"
|
||||
t.string "icon_content_type"
|
||||
t.bigint "icon_file_size"
|
||||
t.datetime "icon_updated_at"
|
||||
t.boolean "trendable"
|
||||
t.datetime "reviewed_at"
|
||||
t.datetime "requested_review_at"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["domain"], name: "index_preview_card_providers_on_domain", unique: true
|
||||
end
|
||||
|
||||
create_table "preview_cards", force: :cascade do |t|
|
||||
t.string "url", default: "", null: false
|
||||
t.string "title", default: "", null: false
|
||||
@@ -710,6 +714,11 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.string "embed_url", default: "", null: false
|
||||
t.integer "image_storage_schema_version"
|
||||
t.string "blurhash"
|
||||
t.string "language"
|
||||
t.float "max_score"
|
||||
t.datetime "max_score_at"
|
||||
t.boolean "trendable"
|
||||
t.integer "link_type"
|
||||
t.index ["url"], name: "index_preview_cards_on_url", unique: true
|
||||
end
|
||||
|
||||
@@ -740,7 +749,6 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
create_table "reports", force: :cascade do |t|
|
||||
t.bigint "status_ids", default: [], null: false, array: true
|
||||
t.text "comment", default: "", null: false
|
||||
t.boolean "action_taken", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id", null: false
|
||||
@@ -749,6 +757,9 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.bigint "assigned_account_id"
|
||||
t.string "uri"
|
||||
t.boolean "forwarded"
|
||||
t.integer "category", default: 0, null: false
|
||||
t.datetime "action_taken_at"
|
||||
t.bigint "rule_ids", array: true
|
||||
t.index ["account_id"], name: "index_reports_on_account_id"
|
||||
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
|
||||
end
|
||||
@@ -805,6 +816,18 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.index ["var"], name: "index_site_uploads_on_var", unique: true
|
||||
end
|
||||
|
||||
create_table "status_edits", force: :cascade do |t|
|
||||
t.bigint "status_id", null: false
|
||||
t.bigint "account_id"
|
||||
t.text "text", default: "", null: false
|
||||
t.text "spoiler_text", default: "", null: false
|
||||
t.boolean "media_attachments_changed", default: false, null: false
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["account_id"], name: "index_status_edits_on_account_id"
|
||||
t.index ["status_id"], name: "index_status_edits_on_status_id"
|
||||
end
|
||||
|
||||
create_table "status_pins", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "status_id", null: false
|
||||
@@ -844,7 +867,9 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.bigint "quote_id"
|
||||
t.bigint "poll_id"
|
||||
t.datetime "deleted_at"
|
||||
t.datetime "edited_at"
|
||||
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
|
||||
t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)"
|
||||
t.index ["id", "account_id"], name: "index_statuses_local_20190824", order: { id: :desc }, where: "((local OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
|
||||
t.index ["id", "account_id"], name: "index_statuses_public_20200119", order: { id: :desc }, where: "((deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
|
||||
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
|
||||
@@ -914,12 +939,9 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.inet "current_sign_in_ip"
|
||||
t.inet "last_sign_in_ip"
|
||||
t.boolean "admin", default: false, null: false
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
@@ -938,7 +960,6 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.boolean "disabled", default: false, null: false
|
||||
t.boolean "moderator", default: false, null: false
|
||||
t.bigint "invite_id"
|
||||
t.string "remember_token"
|
||||
t.string "chosen_languages", array: true
|
||||
t.bigint "created_by_application_id"
|
||||
t.boolean "approved", default: true, null: false
|
||||
@@ -951,7 +972,6 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["remember_token"], name: "index_users_on_remember_token", unique: true
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
||||
@@ -993,7 +1013,6 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
add_foreign_key "account_conversations", "conversations", on_delete: :cascade
|
||||
add_foreign_key "account_deletion_requests", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
|
||||
add_foreign_key "account_identity_proofs", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
|
||||
add_foreign_key "account_migrations", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_moderation_notes", "accounts"
|
||||
@@ -1006,6 +1025,7 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "account_warnings", "accounts", on_delete: :nullify
|
||||
add_foreign_key "account_warnings", "reports", on_delete: :cascade
|
||||
add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
|
||||
add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
|
||||
add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade
|
||||
@@ -1073,6 +1093,8 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
|
||||
add_foreign_key "status_edits", "accounts", on_delete: :nullify
|
||||
add_foreign_key "status_edits", "statuses", on_delete: :cascade
|
||||
add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
|
||||
add_foreign_key "status_pins", "statuses", on_delete: :cascade
|
||||
add_foreign_key "status_stats", "statuses", on_delete: :cascade
|
||||
@@ -1116,6 +1138,28 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
SQL
|
||||
add_index "instances", ["domain"], name: "index_instances_on_domain", unique: true
|
||||
|
||||
create_view "user_ips", sql_definition: <<-SQL
|
||||
SELECT t0.user_id,
|
||||
t0.ip,
|
||||
max(t0.used_at) AS used_at
|
||||
FROM ( SELECT users.id AS user_id,
|
||||
users.sign_up_ip AS ip,
|
||||
users.created_at AS used_at
|
||||
FROM users
|
||||
WHERE (users.sign_up_ip IS NOT NULL)
|
||||
UNION ALL
|
||||
SELECT session_activations.user_id,
|
||||
session_activations.ip,
|
||||
session_activations.updated_at
|
||||
FROM session_activations
|
||||
UNION ALL
|
||||
SELECT login_activities.user_id,
|
||||
login_activities.ip,
|
||||
login_activities.created_at
|
||||
FROM login_activities
|
||||
WHERE (login_activities.success = true)) t0
|
||||
GROUP BY t0.user_id, t0.ip;
|
||||
SQL
|
||||
create_view "account_summaries", materialized: true, sql_definition: <<-SQL
|
||||
SELECT accounts.id AS account_id,
|
||||
mode() WITHIN GROUP (ORDER BY t0.language) AS language,
|
||||
@@ -1125,7 +1169,7 @@ ActiveRecord::Schema.define(version: 2021_08_08_071221) do
|
||||
statuses.language,
|
||||
statuses.sensitive
|
||||
FROM statuses
|
||||
WHERE ((statuses.account_id = accounts.id) AND (statuses.deleted_at IS NULL))
|
||||
WHERE ((statuses.account_id = accounts.id) AND (statuses.deleted_at IS NULL) AND (statuses.reblog_of_id IS NULL))
|
||||
ORDER BY statuses.id DESC
|
||||
LIMIT 20) t0)
|
||||
WHERE ((accounts.suspended_at IS NULL) AND (accounts.silenced_at IS NULL) AND (accounts.moved_to_account_id IS NULL) AND (accounts.discoverable = true) AND (accounts.locked = false))
|
||||
|
||||
23
db/views/account_summaries_v02.sql
Normal file
23
db/views/account_summaries_v02.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
SELECT
|
||||
accounts.id AS account_id,
|
||||
mode() WITHIN GROUP (ORDER BY language ASC) AS language,
|
||||
mode() WITHIN GROUP (ORDER BY sensitive ASC) AS sensitive
|
||||
FROM accounts
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT
|
||||
statuses.account_id,
|
||||
statuses.language,
|
||||
statuses.sensitive
|
||||
FROM statuses
|
||||
WHERE statuses.account_id = accounts.id
|
||||
AND statuses.deleted_at IS NULL
|
||||
AND statuses.reblog_of_id IS NULL
|
||||
ORDER BY statuses.id DESC
|
||||
LIMIT 20
|
||||
) t0
|
||||
WHERE accounts.suspended_at IS NULL
|
||||
AND accounts.silenced_at IS NULL
|
||||
AND accounts.moved_to_account_id IS NULL
|
||||
AND accounts.discoverable = 't'
|
||||
AND accounts.locked = 'f'
|
||||
GROUP BY accounts.id
|
||||
@@ -20,7 +20,7 @@ FROM (
|
||||
HAVING count(follows.id) >= 5
|
||||
UNION ALL
|
||||
SELECT accounts.id AS account_id,
|
||||
sum(reblogs_count + favourites_count) / (1.0 + sum(reblogs_count + favourites_count)) AS rank,
|
||||
sum(status_stats.reblogs_count + status_stats.favourites_count) / (1.0 + sum(status_stats.reblogs_count + status_stats.favourites_count)) AS rank,
|
||||
'most_interactions' AS reason
|
||||
FROM status_stats
|
||||
INNER JOIN statuses ON statuses.id = status_stats.status_id
|
||||
@@ -32,7 +32,7 @@ FROM (
|
||||
AND accounts.locked = 'f'
|
||||
AND accounts.discoverable = 't'
|
||||
GROUP BY accounts.id
|
||||
HAVING sum(reblogs_count + favourites_count) >= 5
|
||||
HAVING sum(status_stats.reblogs_count + status_stats.favourites_count) >= 5
|
||||
) t0
|
||||
GROUP BY account_id
|
||||
ORDER BY rank DESC
|
||||
|
||||
@@ -18,7 +18,7 @@ FROM (
|
||||
HAVING count(follows.id) >= 5
|
||||
UNION ALL
|
||||
SELECT account_summaries.account_id AS account_id,
|
||||
sum(reblogs_count + favourites_count) / (1.0 + sum(reblogs_count + favourites_count)) AS rank,
|
||||
sum(status_stats.reblogs_count + status_stats.favourites_count) / (1.0 + sum(status_stats.reblogs_count + status_stats.favourites_count)) AS rank,
|
||||
'most_interactions' AS reason
|
||||
FROM status_stats
|
||||
INNER JOIN statuses ON statuses.id = status_stats.status_id
|
||||
@@ -28,7 +28,7 @@ FROM (
|
||||
AND account_summaries.sensitive = 'f'
|
||||
AND follow_recommendation_suppressions.id IS NULL
|
||||
GROUP BY account_summaries.account_id
|
||||
HAVING sum(reblogs_count + favourites_count) >= 5
|
||||
HAVING sum(status_stats.reblogs_count + status_stats.favourites_count) >= 5
|
||||
) t0
|
||||
GROUP BY account_id
|
||||
ORDER BY rank DESC
|
||||
|
||||
26
db/views/user_ips_v01.sql
Normal file
26
db/views/user_ips_v01.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
SELECT
|
||||
user_id,
|
||||
ip,
|
||||
max(used_at) AS used_at
|
||||
FROM (
|
||||
SELECT
|
||||
id AS user_id,
|
||||
sign_up_ip AS ip,
|
||||
created_at AS used_at
|
||||
FROM users
|
||||
WHERE sign_up_ip IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT
|
||||
user_id,
|
||||
ip,
|
||||
updated_at
|
||||
FROM session_activations
|
||||
UNION ALL
|
||||
SELECT
|
||||
user_id,
|
||||
ip,
|
||||
created_at
|
||||
FROM login_activities
|
||||
WHERE success = 't'
|
||||
) AS t0
|
||||
GROUP BY user_id, ip
|
||||
Reference in New Issue
Block a user