Enhance AI recommendation caching and onboarding process in company service
continuous-integration/drone/push Build is passing

- Updated `AISummarizerConfig` to allow for a default `RecommendationCacheTTL` of 0, enabling persistent caching until company updates.
- Refactored `StartAIOnboarding` to include cache invalidation and asynchronous recommendation refresh, improving responsiveness during onboarding.
- Introduced `triggerAIOnboardingAsync` method for background processing of AI onboarding and cache refresh, enhancing user experience.
- Improved logging for AI onboarding and recommendation fetching processes, providing better observability and error tracking.

This update optimizes the AI recommendation caching mechanism and onboarding workflow, ensuring a smoother and more efficient experience for users.
This commit is contained in:
Mazyar
2026-06-23 13:43:39 +03:30
parent 326e49886b
commit 20518e7b64
2 changed files with 102 additions and 50 deletions
+3 -2
View File
@@ -69,8 +69,9 @@ type AISummarizerConfig struct {
APIRetryCount int `env:"AI_SUMMARIZER_API_RETRY_COUNT" envDefault:"2"`
APIRetryDelay time.Duration `env:"AI_SUMMARIZER_API_RETRY_DELAY" envDefault:"3s"`
DefaultLanguage string `env:"AI_SUMMARIZER_DEFAULT_LANGUAGE" envDefault:"en"`
// RecommendationCacheTTL caches AI /recommend responses per company. Set to 0 to disable.
RecommendationCacheTTL time.Duration `env:"AI_RECOMMENDATION_CACHE_TTL" envDefault:"15m"`
// RecommendationCacheTTL is an optional max Redis TTL for cached recommendations.
// When 0 (default), entries persist until the company is created, updated, or onboarded.
RecommendationCacheTTL time.Duration `env:"AI_RECOMMENDATION_CACHE_TTL" envDefault:"0"`
// MinIO storage settings
MinioEndpoint string `env:"AI_SUMMARIZER_MINIO_ENDPOINT" envDefault:""`