Shortcut to grab the default entropy configuration

This commit is contained in:
Jorge Manrubia
2025-06-04 12:56:11 +02:00
parent f721bc2c0a
commit dd78ec2db2
4 changed files with 9 additions and 3 deletions
@@ -1,6 +1,6 @@
class Accounts::EntropyConfigurationsController < ApplicationController
def update
Account.sole.default_entropy_configuration.update!(entropy_configuration_params)
Entropy::Configuration.default.update!(entropy_configuration_params)
redirect_to account_settings_path, notice: "Account updated"
end
+1 -1
View File
@@ -8,7 +8,7 @@ module Card::Entropy
scope :entropic_by, ->(period_name) do
left_outer_joins(collection: :entropy_configuration)
.where("last_active_at <= DATETIME('now', '-' || COALESCE(entropy_configurations.#{period_name}, (?)) || ' seconds')",
Entropy::Configuration.where(id: Account.sole.default_entropy_configuration).select(period_name).limit(1))
Entropy::Configuration.where(id: Entropy::Configuration.default).select(period_name).limit(1))
end
scope :stagnated, -> { doing.entropic_by(:auto_reconsider_period) }
+1 -1
View File
@@ -6,7 +6,7 @@ module Collection::Entropy
end
def entropy_configuration
super || Account.sole.default_entropy_configuration
super || Entropy::Configuration.default
end
def auto_close_period=(new_value)
+6
View File
@@ -1,3 +1,9 @@
class Entropy::Configuration < ApplicationRecord
belongs_to :container, polymorphic: true
class << self
def default
Account.sole.default_entropy_configuration
end
end
end