diff --git a/app/models/concerns/landing_host_ai_syncable.rb b/app/models/concerns/landing_host_ai_syncable.rb index 41d77dedd..65330a77b 100644 --- a/app/models/concerns/landing_host_ai_syncable.rb +++ b/app/models/concerns/landing_host_ai_syncable.rb @@ -31,8 +31,16 @@ module LandingHostAiSyncable article = find_or_initialize_faq_article article.title = faq_article_title + article.content = generate_promotions_text(promos) + article.description = "FAQ Gerado automaticamente pela Landing Page: #{hostname}" + # Setting the author as the portal's account first user (just as a fallback) or we can use a system user + article.author ||= default_article_author + article.status = :published - # Generating the standard AI instruction text for the multiple promotions + article.save! + end + + def generate_promotions_text(promos) text = %(INSTRUÇÃO PARA A IA (PROMOÇÕES ATIVAS DO LINK #{hostname}):\n\n) text += %(Existem promoções ativas para os leads que chegam pela landing page '#{hostname}'.\n) text += %(Ofereça a promoção correspondente ao Canal/Origem pelo qual o cliente chegou.\n\n) @@ -47,13 +55,7 @@ module LandingHostAiSyncable text += "\n" end - article.content = text - article.description = "FAQ Gerado automaticamente pela Landing Page: #{hostname}" - # Setting the author as the portal's account first user (just as a fallback) or we can use a system user - article.author ||= default_article_author - article.status = :published - - article.save! + text end def archive_faq_article diff --git a/spec/models/landing_host_spec.rb b/spec/models/landing_host_spec.rb index e787bfd2c..c45ef2a6a 100644 --- a/spec/models/landing_host_spec.rb +++ b/spec/models/landing_host_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe LandingHost, type: :model do let(:account) { create(:account) } - let!(:user) { create(:user, account: account) } let(:portal) { create(:portal, account: account) } let(:inbox) { create(:inbox, account: account, portal: portal) }