Implement AI recommendations for multiple companies and enhance company context handling
continuous-integration/drone/push Build is passing
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:
@@ -101,6 +101,21 @@ func (h *Handler) StartOnboarding(c echo.Context) error {
|
||||
// @Security BearerAuth
|
||||
// @Router /api/v1/recommend [post]
|
||||
func (h *Handler) RecommendTenders(c echo.Context) error {
|
||||
if companyIDs, ok := c.Get("company_ids").([]string); ok && len(companyIDs) > 0 {
|
||||
result, err := h.service.GetMergedAIRecommendations(c.Request().Context(), companyIDs)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrAIRecommendationNotConfigured) {
|
||||
return response.ServiceUnavailable(c, "AI recommendation service is not configured")
|
||||
}
|
||||
if err.Error() == "company not found" {
|
||||
return response.NotFound(c, "Company not found")
|
||||
}
|
||||
return response.InternalServerError(c, "Failed to retrieve AI recommendations")
|
||||
}
|
||||
|
||||
return response.Success(c, result, "AI recommendations retrieved successfully")
|
||||
}
|
||||
|
||||
companyID, err := user.GetCompanyIDFromContext(c)
|
||||
if err != nil {
|
||||
return response.Unauthorized(c, "User not authenticated")
|
||||
|
||||
Reference in New Issue
Block a user