-- ============================================================
-- DANE DEMO dla adsPRO
-- Klient: pomysloweprezenty.pl (client_id = 2)
-- Data generacji: 2026-02-15
-- ============================================================
-- UWAGA: Uruchom ten skrypt TYLKO na bazie testowej/deweloperskiej!
-- Zakłada że klient o id=2 istnieje z google_ads_customer_id = '941-605-1782'
-- ============================================================

-- ============================================================
-- 1. KAMPANIE
-- ============================================================

-- Idempotencja: usuń poprzedni zestaw danych demo kampanii przed ponownym wstawieniem
DELETE ch
FROM campaigns_history ch
JOIN campaigns c ON c.id = ch.campaign_id
WHERE c.client_id = 2
  AND c.campaign_id IN (
    20845671001, 20845671002, 20845671003, 20845671004,
    20845671005, 20845671006, 20845671007, 20845671008
  );

DELETE FROM campaigns
WHERE client_id = 2
  AND campaign_id IN (
    20845671001, 20845671002, 20845671003, 20845671004,
    20845671005, 20845671006, 20845671007, 20845671008
  );

INSERT INTO `campaigns` (`client_id`, `campaign_id`, `campaign_name`) VALUES
(2, 20845671001, 'PMAX | Prezenty personalizowane'),
(2, 20845671002, 'PMAX | Bestsellery'),
(2, 20845671003, 'PMAX | Walentynki 2026'),
(2, 20845671004, 'Shopping | Wszystkie produkty'),
(2, 20845671005, 'Shopping | Prezenty do 50 zł'),
(2, 20845671006, 'Shopping | Prezenty premium'),
(2, 20845671007, 'PMAX | Nowości'),
(2, 20845671008, 'Shopping | Bestsellery high ROAS');

-- Zapamiętaj ID kampanii (zakładam auto_increment od 1)
SET @camp1 = (SELECT id FROM campaigns WHERE campaign_id = 20845671001 AND client_id = 2);
SET @camp2 = (SELECT id FROM campaigns WHERE campaign_id = 20845671002 AND client_id = 2);
SET @camp3 = (SELECT id FROM campaigns WHERE campaign_id = 20845671003 AND client_id = 2);
SET @camp4 = (SELECT id FROM campaigns WHERE campaign_id = 20845671004 AND client_id = 2);
SET @camp5 = (SELECT id FROM campaigns WHERE campaign_id = 20845671005 AND client_id = 2);
SET @camp6 = (SELECT id FROM campaigns WHERE campaign_id = 20845671006 AND client_id = 2);
SET @camp7 = (SELECT id FROM campaigns WHERE campaign_id = 20845671007 AND client_id = 2);
SET @camp8 = (SELECT id FROM campaigns WHERE campaign_id = 20845671008 AND client_id = 2);

-- ============================================================
-- 2. HISTORIA KAMPANII (30 dni: 2026-01-16 do 2026-02-14)
-- ============================================================

-- Generujemy dane dzienne za pomocą procedury
DELIMITER //
DROP PROCEDURE IF EXISTS generate_campaign_history//
CREATE PROCEDURE generate_campaign_history()
BEGIN
  DECLARE i INT DEFAULT 0;
  DECLARE cur_date DATE;
  DECLARE day_factor FLOAT;

  WHILE i < 30 DO
    SET cur_date = DATE_SUB('2026-02-14', INTERVAL i DAY);
    -- Weekendy mają wyższe wydatki (factor 1.2-1.4), dni powszednie normalne
    SET day_factor = CASE DAYOFWEEK(cur_date)
      WHEN 1 THEN 1.3  -- niedziela
      WHEN 7 THEN 1.4  -- sobota
      WHEN 6 THEN 1.1  -- piątek
      ELSE 1.0
    END;

    -- Walentynki boost (7-14 lutego)
    IF cur_date BETWEEN '2026-02-07' AND '2026-02-14' THEN
      SET day_factor = day_factor * 1.5;
    END IF;

    -- PMAX | Prezenty personalizowane (wysoki ROAS, duży budżet)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp1, cur_date,
      ROUND(450 + RAND() * 150, 2),
      ROUND(520 + RAND() * 80, 2),
      150.00,
      ROUND((130 + RAND() * 40) * day_factor, 2),
      ROUND((600 + RAND() * 300) * day_factor, 2),
      'Docelowy ROAS | docelowy ROAS: 400%');

    -- PMAX | Bestsellery (bardzo wysoki ROAS)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp2, cur_date,
      ROUND(650 + RAND() * 200, 2),
      ROUND(700 + RAND() * 100, 2),
      200.00,
      ROUND((170 + RAND() * 60) * day_factor, 2),
      ROUND((1200 + RAND() * 500) * day_factor, 2),
      'Docelowy ROAS | docelowy ROAS: 600%');

    -- PMAX | Walentynki 2026 (sezonowa, wysoki wydatek w lutym)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp3, cur_date,
      ROUND(350 + RAND() * 200 + IF(cur_date >= '2026-02-01', 100, 0), 2),
      ROUND(380 + RAND() * 120, 2),
      ROUND(IF(cur_date >= '2026-02-01', 250, 80), 2),
      ROUND((IF(cur_date >= '2026-02-01', 200, 60) + RAND() * 50) * day_factor, 2),
      ROUND((IF(cur_date >= '2026-02-01', 800, 200) + RAND() * 400) * day_factor, 2),
      'Maksymalizacja wartosci konwersji');

    -- Shopping | Wszystkie produkty (umiarkowany ROAS, duży budżet)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp4, cur_date,
      ROUND(300 + RAND() * 100, 2),
      ROUND(350 + RAND() * 60, 2),
      100.00,
      ROUND((85 + RAND() * 30) * day_factor, 2),
      ROUND((280 + RAND() * 120) * day_factor, 2),
      'Docelowy ROAS | docelowy ROAS: 300%');

    -- Shopping | Prezenty do 50 zł (niski CPC, dobry ROAS)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp5, cur_date,
      ROUND(380 + RAND() * 120, 2),
      ROUND(400 + RAND() * 80, 2),
      50.00,
      ROUND((40 + RAND() * 15) * day_factor, 2),
      ROUND((170 + RAND() * 80) * day_factor, 2),
      'Docelowy ROAS | docelowy ROAS: 350%');

    -- Shopping | Prezenty premium (niski ROAS, wysoki AOV)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp6, cur_date,
      ROUND(200 + RAND() * 100, 2),
      ROUND(250 + RAND() * 80, 2),
      80.00,
      ROUND((65 + RAND() * 25) * day_factor, 2),
      ROUND((150 + RAND() * 100) * day_factor, 2),
      'Maksymalizacja wartosci konwersji');

    -- PMAX | Nowości (nowa kampania, niski ROAS na start)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp7, cur_date,
      ROUND(180 + RAND() * 100 + i * 3, 2),
      ROUND(200 + RAND() * 80, 2),
      60.00,
      ROUND((50 + RAND() * 20) * day_factor, 2),
      ROUND((100 + RAND() * 80 + i * 5) * day_factor, 2),
      'Maksymalizacja liczby konwersji');

    -- Shopping | Bestsellery high ROAS (najlepsza kampania)
    INSERT INTO campaigns_history (campaign_id, date_add, roas_30_days, roas_all_time, budget, money_spent, conversion_value, bidding_strategy) VALUES
    (@camp8, cur_date,
      ROUND(800 + RAND() * 300, 2),
      ROUND(850 + RAND() * 150, 2),
      120.00,
      ROUND((100 + RAND() * 35) * day_factor, 2),
      ROUND((900 + RAND() * 400) * day_factor, 2),
      'Docelowy ROAS | docelowy ROAS: 700%');

    SET i = i + 1;
  END WHILE;
END//
DELIMITER ;

CALL generate_campaign_history();
DROP PROCEDURE IF EXISTS generate_campaign_history;


-- ============================================================
-- 3. PRODUKTY (25 produktów - realistyczne nazwy sklepu z prezentami)
-- ============================================================

-- Idempotencja: usuń poprzedni zestaw danych demo produktów przed ponownym wstawieniem
DELETE pt
FROM products_temp pt
JOIN products p ON p.id = pt.product_id
WHERE p.client_id = 2
  AND p.offer_id IN (
    'shopify_PL_8901001','shopify_PL_8901002','shopify_PL_8901003','shopify_PL_8901004','shopify_PL_8901005',
    'shopify_PL_8901006','shopify_PL_8901007','shopify_PL_8901008','shopify_PL_8901009','shopify_PL_8901010',
    'shopify_PL_8901011','shopify_PL_8901012','shopify_PL_8901013','shopify_PL_8901014','shopify_PL_8901015',
    'shopify_PL_8901016','shopify_PL_8901017','shopify_PL_8901018','shopify_PL_8901019','shopify_PL_8901020',
    'shopify_PL_8901021','shopify_PL_8901022','shopify_PL_8901023','shopify_PL_8901024','shopify_PL_8901025'
  );

DELETE ph
FROM products_history ph
JOIN products p ON p.id = ph.product_id
WHERE p.client_id = 2
  AND p.offer_id IN (
    'shopify_PL_8901001','shopify_PL_8901002','shopify_PL_8901003','shopify_PL_8901004','shopify_PL_8901005',
    'shopify_PL_8901006','shopify_PL_8901007','shopify_PL_8901008','shopify_PL_8901009','shopify_PL_8901010',
    'shopify_PL_8901011','shopify_PL_8901012','shopify_PL_8901013','shopify_PL_8901014','shopify_PL_8901015',
    'shopify_PL_8901016','shopify_PL_8901017','shopify_PL_8901018','shopify_PL_8901019','shopify_PL_8901020',
    'shopify_PL_8901021','shopify_PL_8901022','shopify_PL_8901023','shopify_PL_8901024','shopify_PL_8901025'
  );

DELETE FROM products
WHERE client_id = 2
  AND offer_id IN (
    'shopify_PL_8901001','shopify_PL_8901002','shopify_PL_8901003','shopify_PL_8901004','shopify_PL_8901005',
    'shopify_PL_8901006','shopify_PL_8901007','shopify_PL_8901008','shopify_PL_8901009','shopify_PL_8901010',
    'shopify_PL_8901011','shopify_PL_8901012','shopify_PL_8901013','shopify_PL_8901014','shopify_PL_8901015',
    'shopify_PL_8901016','shopify_PL_8901017','shopify_PL_8901018','shopify_PL_8901019','shopify_PL_8901020',
    'shopify_PL_8901021','shopify_PL_8901022','shopify_PL_8901023','shopify_PL_8901024','shopify_PL_8901025'
  );

INSERT INTO `products` (`client_id`, `offer_id`, `name`) VALUES
(2, 'shopify_PL_8901001', 'Kubek personalizowany ze zdjęciem - Biały 330ml'),
(2, 'shopify_PL_8901002', 'Poduszka z własnym nadrukiem 40x40cm'),
(2, 'shopify_PL_8901003', 'Brelok LED z grawerem - Serce'),
(2, 'shopify_PL_8901004', 'Ramka na zdjęcie z dedykacją - Drewniana A4'),
(2, 'shopify_PL_8901005', 'Puzzle ze zdjęciem 500 elementów'),
(2, 'shopify_PL_8901006', 'Koszulka z nadrukiem - Dla Najlepszego Taty'),
(2, 'shopify_PL_8901007', 'Skarpetki personalizowane - Zestaw 3 par'),
(2, 'shopify_PL_8901008', 'Kubek magiczny zmieniający kolor ze zdjęciem'),
(2, 'shopify_PL_8901009', 'Plakat personalizowany - Mapa Gwiazd A3'),
(2, 'shopify_PL_8901010', 'Biżuteria - Naszyjnik z grawerem Serce'),
(2, 'shopify_PL_8901011', 'Etui na telefon z własnym zdjęciem'),
(2, 'shopify_PL_8901012', 'Torba bawełniana z nadrukiem'),
(2, 'shopify_PL_8901013', 'Kalendarz ze zdjęciami 2026 - Ścienny A3'),
(2, 'shopify_PL_8901014', 'Podkładka pod mysz z własnym zdjęciem'),
(2, 'shopify_PL_8901015', 'Zestaw upominkowy - Kubek + Podkładka + Brelok'),
(2, 'shopify_PL_8901016', 'Obraz na płótnie Canvas 60x40cm ze zdjęciem'),
(2, 'shopify_PL_8901017', 'Otwieracz do butelek z grawerem'),
(2, 'shopify_PL_8901018', 'Fotokolaż na płótnie 50x70cm'),
(2, 'shopify_PL_8901019', 'Koc z nadrukiem polarowy 150x200cm'),
(2, 'shopify_PL_8901020', 'Piersiówka z grawerem 200ml'),
(2, 'shopify_PL_8901021', 'Zegar ścienny ze zdjęciem - Okrągły 30cm'),
(2, 'shopify_PL_8901022', 'Ręcznik z haftem imienia 70x140cm'),
(2, 'shopify_PL_8901023', 'Walentynkowy zestaw - Kubek + Czekolada + Kartka'),
(2, 'shopify_PL_8901024', 'Magnes na lodówkę z własnym zdjęciem'),
(2, 'shopify_PL_8901025', 'Szkatułka drewniana z grawerem');

-- ============================================================
-- 4. HISTORIA PRODUKTÓW (30 dni dziennych danych)
-- ============================================================

DELIMITER //
DROP PROCEDURE IF EXISTS generate_product_history//
CREATE PROCEDURE generate_product_history()
BEGIN
  DECLARE i INT DEFAULT 0;
  DECLARE j INT DEFAULT 1;
  DECLARE cur_date DATE;
  DECLARE prod_id INT;
  DECLARE base_imp INT;
  DECLARE base_clicks INT;
  DECLARE base_cost DECIMAL(10,2);
  DECLARE base_conv INT;
  DECLARE base_conv_val DECIMAL(10,2);
  DECLARE day_imp INT;
  DECLARE day_clicks INT;
  DECLARE day_cost DECIMAL(10,2);
  DECLARE day_conv INT;
  DECLARE day_conv_val DECIMAL(10,2);
  DECLARE day_ctr DECIMAL(6,4);
  DECLARE day_factor FLOAT;
  DECLARE product_count INT;

  SET product_count = 25;

  -- Dla każdego produktu
  SET j = 1;
  WHILE j <= product_count DO
    -- Pobierz ID produktu
    SET prod_id = (SELECT id FROM products WHERE client_id = 2 AND offer_id = CONCAT('shopify_PL_890100', j) LIMIT 1);
    IF prod_id IS NULL AND j >= 10 THEN
      SET prod_id = (SELECT id FROM products WHERE client_id = 2 AND offer_id = CONCAT('shopify_PL_89010', j) LIMIT 1);
    END IF;

    -- Bazowe metryki różne per produkt (symulacja różnej popularności)
    CASE j
      WHEN 1 THEN SET base_imp = 850, base_clicks = 45, base_cost = 12.50, base_conv = 3, base_conv_val = 89.70;    -- Kubek - bestseller
      WHEN 2 THEN SET base_imp = 620, base_clicks = 32, base_cost = 9.80, base_conv = 2, base_conv_val = 79.80;     -- Poduszka
      WHEN 3 THEN SET base_imp = 1200, base_clicks = 68, base_cost = 15.20, base_conv = 5, base_conv_val = 74.75;   -- Brelok LED - top impressions
      WHEN 4 THEN SET base_imp = 380, base_clicks = 18, base_cost = 7.20, base_conv = 1, base_conv_val = 59.90;     -- Ramka
      WHEN 5 THEN SET base_imp = 520, base_clicks = 28, base_cost = 11.00, base_conv = 2, base_conv_val = 99.80;    -- Puzzle
      WHEN 6 THEN SET base_imp = 780, base_clicks = 42, base_cost = 13.50, base_conv = 3, base_conv_val = 89.70;    -- Koszulka
      WHEN 7 THEN SET base_imp = 450, base_clicks = 22, base_cost = 6.80, base_conv = 2, base_conv_val = 49.90;     -- Skarpetki
      WHEN 8 THEN SET base_imp = 680, base_clicks = 38, base_cost = 10.50, base_conv = 2, base_conv_val = 69.90;    -- Kubek magiczny
      WHEN 9 THEN SET base_imp = 920, base_clicks = 55, base_cost = 18.00, base_conv = 4, base_conv_val = 159.60;   -- Plakat mapa gwiazd - wysoki AOV
      WHEN 10 THEN SET base_imp = 1100, base_clicks = 72, base_cost = 22.00, base_conv = 5, base_conv_val = 349.50; -- Naszyjnik - top conversion value
      WHEN 11 THEN SET base_imp = 550, base_clicks = 30, base_cost = 8.50, base_conv = 1, base_conv_val = 39.90;    -- Etui
      WHEN 12 THEN SET base_imp = 320, base_clicks = 14, base_cost = 4.20, base_conv = 1, base_conv_val = 29.90;    -- Torba
      WHEN 13 THEN SET base_imp = 280, base_clicks = 12, base_cost = 5.00, base_conv = 0, base_conv_val = 0.00;     -- Kalendarz - słaby (po sezonie)
      WHEN 14 THEN SET base_imp = 180, base_clicks = 8, base_cost = 2.50, base_conv = 0, base_conv_val = 0.00;      -- Podkładka - zombie
      WHEN 15 THEN SET base_imp = 740, base_clicks = 40, base_cost = 14.00, base_conv = 3, base_conv_val = 179.70;  -- Zestaw upominkowy
      WHEN 16 THEN SET base_imp = 480, base_clicks = 25, base_cost = 16.00, base_conv = 1, base_conv_val = 149.00;  -- Canvas
      WHEN 17 THEN SET base_imp = 350, base_clicks = 18, base_cost = 5.50, base_conv = 1, base_conv_val = 34.90;    -- Otwieracz
      WHEN 18 THEN SET base_imp = 410, base_clicks = 22, base_cost = 14.00, base_conv = 1, base_conv_val = 189.00;  -- Fotokolaż
      WHEN 19 THEN SET base_imp = 290, base_clicks = 15, base_cost = 9.00, base_conv = 1, base_conv_val = 119.00;   -- Koc
      WHEN 20 THEN SET base_imp = 420, base_clicks = 24, base_cost = 7.00, base_conv = 1, base_conv_val = 69.90;    -- Piersiówka
      WHEN 21 THEN SET base_imp = 260, base_clicks = 11, base_cost = 4.50, base_conv = 0, base_conv_val = 0.00;     -- Zegar - słaby
      WHEN 22 THEN SET base_imp = 340, base_clicks = 16, base_cost = 6.00, base_conv = 1, base_conv_val = 59.90;    -- Ręcznik
      WHEN 23 THEN SET base_imp = 1500, base_clicks = 95, base_cost = 28.00, base_conv = 8, base_conv_val = 319.20; -- Walentynkowy zestaw - HIT
      WHEN 24 THEN SET base_imp = 150, base_clicks = 6, base_cost = 1.80, base_conv = 0, base_conv_val = 0.00;      -- Magnes - zombie
      WHEN 25 THEN SET base_imp = 380, base_clicks = 20, base_cost = 8.00, base_conv = 1, base_conv_val = 89.90;    -- Szkatułka
      ELSE SET base_imp = 300, base_clicks = 15, base_cost = 5.00, base_conv = 1, base_conv_val = 50.00;
    END CASE;

    -- 30 dni historii
    SET i = 0;
    WHILE i < 30 DO
      SET cur_date = DATE_SUB('2026-02-14', INTERVAL i DAY);

      SET day_factor = CASE DAYOFWEEK(cur_date)
        WHEN 1 THEN 1.25
        WHEN 7 THEN 1.35
        WHEN 6 THEN 1.1
        ELSE 1.0
      END;

      -- Walentynki boost (szczególnie produkty walentynkowe: j=23, j=10, j=9)
      IF cur_date BETWEEN '2026-02-07' AND '2026-02-14' THEN
        IF j IN (23, 10, 9, 3, 1) THEN
          SET day_factor = day_factor * 2.0;
        ELSE
          SET day_factor = day_factor * 1.3;
        END IF;
      END IF;

      SET day_imp = ROUND(base_imp * day_factor * (0.8 + RAND() * 0.4));
      SET day_clicks = ROUND(base_clicks * day_factor * (0.7 + RAND() * 0.6));
      SET day_cost = ROUND(base_cost * day_factor * (0.8 + RAND() * 0.4), 2);
      -- Konwersje: losowe z prawdopodobieństwem bazowym
      SET day_conv = FLOOR(base_conv * day_factor * (0.3 + RAND() * 1.4));
      SET day_conv_val = ROUND(IF(day_conv > 0, day_conv * (base_conv_val / GREATEST(base_conv, 1)) * (0.9 + RAND() * 0.2), 0), 2);
      SET day_ctr = IF(day_imp > 0, ROUND(day_clicks / day_imp, 4) * 100, 0);

      IF prod_id IS NOT NULL THEN
        INSERT INTO products_history (product_id, date_add, impressions, clicks, ctr, cost, conversions, conversions_value, updated) VALUES
        (prod_id, cur_date, day_imp, day_clicks, day_ctr, day_cost, day_conv, day_conv_val, 0);
      END IF;

      SET i = i + 1;
    END WHILE;

    SET j = j + 1;
  END WHILE;
END//
DELIMITER ;

CALL generate_product_history();
DROP PROCEDURE IF EXISTS generate_product_history;


-- ============================================================
-- 5. PRODUCTS_TEMP (zagregowane dane - jak po cron_products)
-- ============================================================

-- Idempotencja: wyczyść bieżące agregaty klienta przed ponownym przeliczeniem
DELETE pt
FROM products_temp pt
JOIN products p ON p.id = pt.product_id
WHERE p.client_id = 2;

INSERT INTO products_temp (product_id, name, impressions, impressions_30, clicks, clicks_30, ctr, cost, conversions, conversions_value, cpc, roas)
SELECT
  p.id,
  p.name,
  COALESCE(SUM(ph.impressions), 0),
  COALESCE(SUM(ph.impressions), 0),
  COALESCE(SUM(ph.clicks), 0),
  COALESCE(SUM(ph.clicks), 0),
  CASE WHEN SUM(ph.impressions) > 0 THEN ROUND(SUM(ph.clicks) / SUM(ph.impressions) * 100, 2) ELSE 0 END,
  COALESCE(SUM(ph.cost), 0),
  COALESCE(SUM(ph.conversions), 0),
  COALESCE(SUM(ph.conversions_value), 0),
  CASE WHEN SUM(ph.clicks) > 0 THEN ROUND(SUM(ph.cost) / SUM(ph.clicks), 6) ELSE 0 END,
  CASE WHEN SUM(ph.conversions) > 0 AND SUM(ph.cost) > 0 THEN ROUND(SUM(ph.conversions_value) / SUM(ph.cost) * 100, 2) ELSE 0 END
FROM products p
LEFT JOIN products_history ph ON p.id = ph.product_id
WHERE p.client_id = 2
GROUP BY p.id, p.name;


-- ============================================================
-- 6. PRODUCTS (custom labels)
-- ============================================================

-- Bestsellery (wysoki ROAS + dużo konwersji)
UPDATE products SET custom_label_4 = 'bestseller' WHERE offer_id IN ( 'shopify_PL_8901001', 'shopify_PL_8901003', 'shopify_PL_8901010', 'shopify_PL_8901023' ) AND client_id = 2;

-- Produkty PLA (w kampaniach Shopping)
UPDATE products SET custom_label_4 = 'pla' WHERE offer_id IN ( 'shopify_PL_8901005', 'shopify_PL_8901006', 'shopify_PL_8901015' ) AND client_id = 2;

-- Zombie (bardzo niskie wyświetlenia)
UPDATE products SET custom_label_4 = 'zombie' WHERE offer_id IN ( 'shopify_PL_8901014', 'shopify_PL_8901024' ) AND client_id = 2;


-- ============================================================
-- 7. MIN ROAS per klient (bestseller threshold)
-- ============================================================

-- Ustaw min ROAS dla wybranych produktów
UPDATE products SET min_roas = 500 WHERE offer_id = 'shopify_PL_8901001' AND client_id = 2;
UPDATE products SET min_roas = 400 WHERE offer_id = 'shopify_PL_8901003' AND client_id = 2;
UPDATE products SET min_roas = 600 WHERE offer_id = 'shopify_PL_8901010' AND client_id = 2;
UPDATE products SET min_roas = 350 WHERE offer_id = 'shopify_PL_8901023' AND client_id = 2;


-- ============================================================
-- GOTOWE!
-- Po wykonaniu tego skryptu:
-- 1. Wejdź na /campaigns → wybierz klienta pomysloweprezenty.pl
--    → zobaczysz 8 kampanii z 30-dniową historią
-- 2. Wejdź na /products → wybierz klienta
--    → zobaczysz 25 produktów z metrykami
-- 3. Kliknij dowolny produkt → zobaczysz historię i wykres
-- ============================================================
