mirror of
https://github.com/we-promise/sure.git
synced 2026-04-18 19:44:09 +00:00
Implement Run all rules (#582)
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user