mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Upgrade Rails to version 7.2
This commit is contained in:
committed by
Loïc Guitaut
parent
f4d0a77d5f
commit
d6bec460a8
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
class ApplicationRequest < ActiveRecord::Base
|
||||
enum req_type: {
|
||||
enum :req_type,
|
||||
{
|
||||
http_total: 0,
|
||||
http_2xx: 1,
|
||||
http_background: 2,
|
||||
|
||||
@@ -4,7 +4,7 @@ class DirectoryColumn < ActiveRecord::Base
|
||||
self.ignored_columns = ["automatic"] # TODO: Remove when 20240212034010_drop_deprecated_columns has been promoted to pre-deploy
|
||||
self.inheritance_column = nil
|
||||
|
||||
enum type: { automatic: 0, user_field: 1, plugin: 2 }, _scopes: false
|
||||
enum :type, { automatic: 0, user_field: 1, plugin: 2 }, scopes: false
|
||||
|
||||
def self.automatic_column_names
|
||||
@automatic_column_names ||= %i[
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
class PostHotlinkedMedia < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
belongs_to :upload
|
||||
enum status: {
|
||||
enum :status,
|
||||
{
|
||||
downloaded: "downloaded",
|
||||
too_large: "too_large",
|
||||
download_failed: "download_failed",
|
||||
|
||||
@@ -417,7 +417,7 @@ class RemoteTheme < ActiveRecord::Base
|
||||
self.commits_behind = 0
|
||||
end
|
||||
|
||||
transaction_block = -> do
|
||||
transaction_block = ->(*) do
|
||||
# Destroy fields that no longer exist in the remote theme
|
||||
field_ids_to_destroy = theme.theme_fields.pluck(:id) - updated_fields.map { |tf| tf&.id }
|
||||
ThemeField.where(id: field_ids_to_destroy).destroy_all
|
||||
|
||||
@@ -4,10 +4,10 @@ class ReviewableHistory < ActiveRecord::Base
|
||||
belongs_to :reviewable
|
||||
belongs_to :created_by, class_name: "User"
|
||||
|
||||
enum status: { pending: 0, approved: 1, rejected: 2, ignored: 3, deleted: 4 }
|
||||
enum :status, { pending: 0, approved: 1, rejected: 2, ignored: 3, deleted: 4 }
|
||||
|
||||
alias_attribute :type, :reviewable_history_type
|
||||
enum type: { created: 0, transitioned: 1, edited: 2, claimed: 3, unclaimed: 4 }
|
||||
enum :type, { created: 0, transitioned: 1, edited: 2, claimed: 3, unclaimed: 4 }
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
||||
@@ -6,7 +6,7 @@ class ReviewableScore < ActiveRecord::Base
|
||||
belongs_to :reviewed_by, class_name: "User"
|
||||
belongs_to :meta_topic, class_name: "Topic"
|
||||
|
||||
enum status: { pending: 0, agreed: 1, disagreed: 2, ignored: 3 }
|
||||
enum :status, { pending: 0, agreed: 1, disagreed: 2, ignored: 3 }
|
||||
|
||||
# To keep things simple the types correspond to `PostActionType` for backwards
|
||||
# compatibility, but we can add extra reasons for scores.
|
||||
|
||||
@@ -863,7 +863,7 @@ class Theme < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def migrate_settings(start_transaction: true, fields: nil, allow_out_of_sequence_migration: false)
|
||||
block = -> do
|
||||
block = ->(*) do
|
||||
runner = ThemeSettingsMigrationsRunner.new(self)
|
||||
results =
|
||||
runner.run(fields:, raise_error_on_out_of_sequence: !allow_out_of_sequence_migration)
|
||||
|
||||
@@ -238,31 +238,34 @@ class TopicTrackingState
|
||||
end
|
||||
|
||||
def self.new_filter_sql
|
||||
TopicQuery
|
||||
.new_filter(Topic, treat_as_new_topic_clause_sql: treat_as_new_topic_clause)
|
||||
.where_clause
|
||||
.ast
|
||||
.to_sql + " AND topics.created_at > :min_new_topic_date" +
|
||||
" AND dismissed_topic_users.id IS NULL"
|
||||
ActiveRecord::Base.connection.to_sql(
|
||||
TopicQuery
|
||||
.new_filter(Topic, treat_as_new_topic_clause_sql: treat_as_new_topic_clause)
|
||||
.where_clause
|
||||
.ast,
|
||||
) + " AND topics.created_at > :min_new_topic_date" + " AND dismissed_topic_users.id IS NULL"
|
||||
end
|
||||
|
||||
def self.unread_filter_sql(whisperer: false)
|
||||
TopicQuery.unread_filter(Topic, whisperer: whisperer).where_clause.ast.to_sql
|
||||
ActiveRecord::Base.connection.to_sql(
|
||||
TopicQuery.unread_filter(Topic, whisperer: whisperer).where_clause.ast,
|
||||
)
|
||||
end
|
||||
|
||||
def self.treat_as_new_topic_clause
|
||||
User
|
||||
.where(
|
||||
"GREATEST(CASE
|
||||
ActiveRecord::Base.connection.to_sql(
|
||||
User
|
||||
.where(
|
||||
"GREATEST(CASE
|
||||
WHEN COALESCE(uo.new_topic_duration_minutes, :default_duration) = :always THEN u.created_at
|
||||
WHEN COALESCE(uo.new_topic_duration_minutes, :default_duration) = :last_visit THEN COALESCE(u.previous_visit_at,u.created_at)
|
||||
ELSE (:now::timestamp - INTERVAL '1 MINUTE' * COALESCE(uo.new_topic_duration_minutes, :default_duration))
|
||||
END, u.created_at, :min_date)",
|
||||
treat_as_new_topic_params,
|
||||
)
|
||||
.where_clause
|
||||
.ast
|
||||
.to_sql
|
||||
treat_as_new_topic_params,
|
||||
)
|
||||
.where_clause
|
||||
.ast,
|
||||
)
|
||||
end
|
||||
|
||||
def self.treat_as_new_topic_params
|
||||
|
||||
@@ -52,7 +52,7 @@ class TranslationOverride < ActiveRecord::Base
|
||||
validate :check_MF_string, if: :message_format?
|
||||
|
||||
attribute :status, :integer
|
||||
enum status: { up_to_date: 0, outdated: 1, invalid_interpolation_keys: 2, deprecated: 3 }
|
||||
enum :status, { up_to_date: 0, outdated: 1, invalid_interpolation_keys: 2, deprecated: 3 }
|
||||
|
||||
scope :mf_locales,
|
||||
->(locale) { not_deprecated.where(locale: locale).where("translation_key LIKE '%_MF'") }
|
||||
|
||||
@@ -26,7 +26,7 @@ class UserOption < ActiveRecord::Base
|
||||
|
||||
scope :human_users, -> { where("user_id > 0") }
|
||||
|
||||
enum default_calendar: { none_selected: 0, ics: 1, google: 2 }, _scopes: false
|
||||
enum :default_calendar, { none_selected: 0, ics: 1, google: 2 }, scopes: false
|
||||
|
||||
def self.ensure_consistency!
|
||||
sql = <<~SQL
|
||||
|
||||
@@ -18,7 +18,8 @@ class WebHookEventType < ActiveRecord::Base
|
||||
TOPIC_VOTING = 17
|
||||
CHAT_MESSAGE = 18
|
||||
|
||||
enum group: {
|
||||
enum :group,
|
||||
{
|
||||
topic: 0,
|
||||
post: 1,
|
||||
user: 2,
|
||||
@@ -37,7 +38,7 @@ class WebHookEventType < ActiveRecord::Base
|
||||
chat: 15,
|
||||
custom: 16,
|
||||
},
|
||||
_scopes: false
|
||||
scopes: false
|
||||
|
||||
TYPES = {
|
||||
topic_created: 101,
|
||||
|
||||
Reference in New Issue
Block a user