diff --git a/AzureFunction/GoogleStorageController.cs b/AzureFunction/GoogleStorageController.cs index bda9f9f..be2ce5d 100644 --- a/AzureFunction/GoogleStorageController.cs +++ b/AzureFunction/GoogleStorageController.cs @@ -65,30 +65,24 @@ namespace OSAFeedXML bon_ec_name AS title, bon_seo_description AS description, CONCAT('{DomainRedirect}/produkt/', bon_slug_url, '--s-', bon_gid) AS link, - COALESCE(ic.bon_url, bn.bon_url) AS image_link, + CASE WHEN {WithoutBg} THEN ic.bon_url ELSE bn.bon_url END AS image_link, CASE WHEN bon_warehouse_state_central IS NULL OR bon_warehouse_state_central = 0 THEN 'out_of_stock' WHEN NOT EXISTS ( SELECT 1 FROM UNNEST(bon_marketplace) AS marketplace_value WHERE marketplace_value IN UNNEST([{string.Join(", ", Destinations.Select(dest => (int)dest))}]) - ) - OR bon_ecommerce_status NOT IN ({string.Join(", ", status.Select(stat => (int)stat))}) THEN 'out_of_stock' + ) OR bon_ecommerce_status NOT IN ({string.Join(", ", status.Select(stat => (int)stat))}) THEN 'out_of_stock' ELSE 'in_stock' END AS availability, - ROUND( - bon_cash_price * - (CASE WHEN bon_price_for = {(int)PriceConversion.CONVERTION} THEN bon_converter ELSE 1 END) * - ((100 + COALESCE(bon_vat_rate, 0)) / 100), 2 - ) AS price, + ROUND((bon_cash_price * (CASE WHEN bon_price_for = {(int)PriceConversion.CONVERTION} THEN bon_converter ELSE 1 END) * ((100 + bon_vat_rate) / 100)), 2) AS price, bon_category_path AS product_type, bon_name AS brand, bon_ean AS gtin, bon_index AS mpn, osa_gmc_id AS google_product_category FROM `{GoogleProjectId}.{GoogleDatabase}.bon_main_product` bn - LEFT JOIN `{GoogleProjectId}.{GoogleDatabase}.images_clearbg` ic - ON bn.bon_commodity_indexid = ic.bon_commodity_indexid + { (WithoutBg ? $"JOIN `{GoogleProjectId}.{GoogleDatabase}.images_clearbg` ic ON bn.bon_commodity_indexid = ic.bon_commodity_indexid" : "JOIN (SELECT '1' AS bon_url) AS ic ON ic.bon_url = '1'") } "; BigQueryResults results = bigqueryClient.ExecuteQuery(sql, null);