From dd78ec2db2cd68119df3d114f1b544bc33c4b553 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Wed, 4 Jun 2025 12:56:11 +0200 Subject: [PATCH] Shortcut to grab the default entropy configuration --- .../accounts/entropy_configurations_controller.rb | 2 +- app/models/card/entropy.rb | 2 +- app/models/collection/entropy.rb | 2 +- app/models/entropy/configuration.rb | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/accounts/entropy_configurations_controller.rb b/app/controllers/accounts/entropy_configurations_controller.rb index 7781512f6..07e828242 100644 --- a/app/controllers/accounts/entropy_configurations_controller.rb +++ b/app/controllers/accounts/entropy_configurations_controller.rb @@ -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 diff --git a/app/models/card/entropy.rb b/app/models/card/entropy.rb index 7aec14ac3..41fcd4cfd 100644 --- a/app/models/card/entropy.rb +++ b/app/models/card/entropy.rb @@ -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) } diff --git a/app/models/collection/entropy.rb b/app/models/collection/entropy.rb index ddf0883f4..b7b55133b 100644 --- a/app/models/collection/entropy.rb +++ b/app/models/collection/entropy.rb @@ -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) diff --git a/app/models/entropy/configuration.rb b/app/models/entropy/configuration.rb index 72370670f..4ed13d597 100644 --- a/app/models/entropy/configuration.rb +++ b/app/models/entropy/configuration.rb @@ -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