mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Add AI cache clearing infrastructure
Add ClearAiCacheJob for async cache clearing with low priority. Extend Enrichable concern with clear_ai_cache methods to unlock AI-enriched attributes and delete AI enrichment records. Trigger automatic cache clearing when OpenAI model setting changes.
This commit is contained in:
@@ -80,6 +80,8 @@ class Setting < RailsSettings::Base
|
||||
class << self
|
||||
alias_method :raw_onboarding_state, :onboarding_state
|
||||
alias_method :raw_onboarding_state=, :onboarding_state=
|
||||
alias_method :raw_openai_model, :openai_model
|
||||
alias_method :raw_openai_model=, :openai_model=
|
||||
|
||||
def onboarding_state
|
||||
value = raw_onboarding_state
|
||||
@@ -94,6 +96,18 @@ class Setting < RailsSettings::Base
|
||||
self.raw_onboarding_state = state
|
||||
end
|
||||
|
||||
def openai_model=(value)
|
||||
old_value = raw_openai_model
|
||||
self.raw_openai_model = value
|
||||
|
||||
if old_value != value && old_value.present?
|
||||
Rails.logger.info("OpenAI model changed from #{old_value} to #{value}, clearing AI cache for all families")
|
||||
Family.find_each do |family|
|
||||
ClearAiCacheJob.perform_later(family)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Support dynamic field access via bracket notation
|
||||
# First checks if it's a declared field, then falls back to individual dynamic entries
|
||||
def [](key)
|
||||
|
||||
Reference in New Issue
Block a user