Implement Run all rules (#582)

This commit is contained in:
soky srm
2026-01-08 15:20:14 +01:00
committed by GitHub
parent c315e08a6e
commit e37c03d1d4
11 changed files with 239 additions and 0 deletions

View File

@@ -104,6 +104,30 @@ class RulesController < ApplicationController
redirect_to rules_path, notice: "All rules deleted"
end
def confirm_all
@rules = Current.family.rules
@total_affected_count = Rule.total_affected_resource_count(@rules)
# Compute AI cost estimation if any rule has auto_categorize action
if @rules.any? { |r| r.actions.any? { |a| a.action_type == "auto_categorize" } }
llm_provider = Provider::Registry.get_provider(:openai)
if llm_provider
@selected_model = Provider::Openai.effective_model
@estimated_cost = LlmUsage.estimate_auto_categorize_cost(
transaction_count: @total_affected_count,
category_count: Current.family.categories.count,
model: @selected_model
)
end
end
end
def apply_all
ApplyAllRulesJob.perform_later(Current.family)
redirect_back_or_to rules_path, notice: t("rules.apply_all.success")
end
private
def set_rule
@rule = Current.family.rules.find(params[:id])