diff --git a/internal/ym/products/repository_api.go b/internal/ym/products/repository_api.go index 3579589..da42e96 100644 --- a/internal/ym/products/repository_api.go +++ b/internal/ym/products/repository_api.go @@ -254,7 +254,7 @@ func (r *apiRepository) CalculateProductTariffs(ctx context.Context, marketplace func (r *apiRepository) setTariffsRateLimit() { ym.SetPathLimit("/tariffs/calculate", rateLimitWindow, tariffsRateLimit) } -func getCategoriesError(bodyData string) []int64 { +func GetCategoriesError(bodyData string) []int64 { var result []int64 for _, v := range gjson.Get(bodyData, "errors.#.message").Array() { errorMessage := v.String() @@ -280,7 +280,7 @@ func getCategoriesError(bodyData string) []int64 { func filterOffersByCategories(offers []*pb.CalculateProductTariffsRequest_Offer, categories []int64) []*pb.CalculateProductTariffsRequest_Offer { return lo.Filter(offers, func(offer *pb.CalculateProductTariffsRequest_Offer, _ int) bool { - return lo.Contains(categories, offer.CategoryId) + return !lo.Contains(categories, offer.CategoryId) }) } @@ -321,7 +321,7 @@ func (r *apiRepository) processTariffChunk(ctx context.Context, client *ymclient return nil, fmt.Errorf("failed to read response body for chunk %d: %w", chunkIndex+1, httpErr) } fmt.Printf("Error response for chunk %d: %s\n", chunkIndex+1, string(bodyData)) - categoriesErrors := getCategoriesError(string(bodyData)) + categoriesErrors := GetCategoriesError(string(bodyData)) if len(categoriesErrors) == 0 { return nil, fmt.Errorf("failed to call Yandex Market API for chunk %d: %w", chunkIndex+1, err) }