Implement AI recommendations for multiple companies and enhance company context handling
continuous-integration/drone/push Build is passing

- Added functionality to retrieve merged AI recommendations for multiple companies, improving the relevance of tender suggestions based on company-specific data.
- Introduced normalization functions to clean and deduplicate company IDs, ensuring accurate processing of recommendations.
- Enhanced the company context resolution in customer middleware to support multiple assigned companies, improving the handling of company-specific requests.
- Updated the tender recommendation logic to utilize the new merged recommendations and handle exclusions for rejected tenders accordingly.
- Added unit tests to verify the new recommendation merging logic and company ID normalization, ensuring robust functionality.

This update significantly enhances the tender recommendation process by allowing for more comprehensive and relevant suggestions based on multiple company contexts, improving user experience and satisfaction.
This commit is contained in:
Mazyar
2026-07-04 13:00:33 +03:30
parent f8c98da132
commit 1edf42187d
12 changed files with 280 additions and 22 deletions
+16 -2
View File
@@ -354,7 +354,22 @@ func (h *TenderHandler) RecommendTenders(c echo.Context) error {
form.OnlyActiveDeadlines = true
form.ExcludeRejectedTenders = true
if customerCompanyID, ok := c.Get("company_id").(string); ok && customerCompanyID != "" {
if customerIDStr, ok := c.Get("customer_id").(string); ok && customerIDStr != "" {
form.CustomerID = &customerIDStr
}
requestedCompanyID := ""
if form.CompanyID != nil {
requestedCompanyID = strings.TrimSpace(*form.CompanyID)
}
if requestedCompanyID != "" {
if customerCompanyID, ok := c.Get("company_id").(string); ok && customerCompanyID != "" {
form.CompanyID = &customerCompanyID
}
} else if customerCompanyIDs, ok := c.Get("company_ids").([]string); ok && len(customerCompanyIDs) > 0 {
form.CompanyIDs = append([]string(nil), customerCompanyIDs...)
} else if customerCompanyID, ok := c.Get("company_id").(string); ok && customerCompanyID != "" {
form.CompanyID = &customerCompanyID
}
@@ -820,4 +835,3 @@ func (h *TenderHandler) GetAllAISummaries(c echo.Context) error {
return response.Success(c, summaries, "AI summaries retrieved successfully")
}