-- Meyer Experiments Seed Data (Corrected)
-- This file contains all 40 Meyer experiments from post_workshop_meyer_experiments.csv
-- Each experiment has only 1 repetition required
-- Updated to match the actual CSV data with correct experiment numbers and parameters

-- =============================================
-- INSERT MEYER EXPERIMENTS (Post Workshop)
-- =============================================

-- Insert Meyer experiments (experiments 1-40) with data from CSV
INSERT INTO public.experiments (
    experiment_number,
    reps_required,
    results_status,
    completion_status,
    phase_id,
    created_by
) VALUES
-- Meyer Experiments 1-40 (matching CSV data)
(1, 1, 'valid', false, 
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(2, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(3, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(4, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(5, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(6, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(7, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(8, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(9, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(10, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(11, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(12, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(13, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(14, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(15, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(16, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(17, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(18, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(19, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(20, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(21, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(22, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(23, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(24, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(25, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(26, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(27, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(28, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(29, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(30, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(31, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(32, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(33, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(34, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(35, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(36, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(37, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(38, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(39, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com')),
(40, 1, 'valid', false,
 (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments'),
 (SELECT id FROM public.user_profiles WHERE email = 's.alireza.v@gmail.com'))
ON CONFLICT (experiment_number, phase_id) DO NOTHING;

-- =============================================
-- CREATE SOAKING PHASE RECORDS FOR MEYER EXPERIMENTS
-- =============================================

-- Create soaking records for Meyer experiments (1-40) with data from CSV
INSERT INTO public.soaking (
    experiment_id,
    scheduled_start_time,
    soaking_duration_minutes,
    scheduled_end_time,
    created_by
)
SELECT 
    e.id,
    NOW() + e.experiment_number * INTERVAL '1 day',
    CASE e.experiment_number
        WHEN 1 THEN 27 * 60  -- 27 hours = 1620 minutes
        WHEN 2 THEN 37 * 60  -- 37 hours = 2220 minutes
        WHEN 3 THEN 36 * 60  -- 36 hours = 2160 minutes
        WHEN 4 THEN 12 * 60  -- 12 hours = 720 minutes
        WHEN 5 THEN 34 * 60  -- 34 hours = 2040 minutes
        WHEN 6 THEN 18 * 60  -- 18 hours = 1080 minutes
        WHEN 7 THEN 14 * 60  -- 14 hours = 840 minutes
        WHEN 8 THEN 18 * 60  -- 18 hours = 1080 minutes
        WHEN 9 THEN 11 * 60  -- 11 hours = 660 minutes
        WHEN 10 THEN 33 * 60  -- 33 hours = 1980 minutes
        WHEN 11 THEN 23 * 60  -- 23 hours = 1380 minutes
        WHEN 12 THEN 37 * 60  -- 37 hours = 2220 minutes
        WHEN 13 THEN 15 * 60  -- 15 hours = 900 minutes
        WHEN 14 THEN 24 * 60  -- 24 hours = 1440 minutes
        WHEN 15 THEN 36 * 60  -- 36 hours = 2160 minutes
        WHEN 16 THEN 32 * 60  -- 32 hours = 1920 minutes
        WHEN 17 THEN 28 * 60  -- 28 hours = 1680 minutes
        WHEN 18 THEN 31 * 60  -- 31 hours = 1860 minutes
        WHEN 19 THEN 20 * 60  -- 20 hours = 1200 minutes
        WHEN 20 THEN 10 * 60  -- 10 hours = 600 minutes
        WHEN 21 THEN 16 * 60  -- 16 hours = 960 minutes
        WHEN 22 THEN 21 * 60  -- 21 hours = 1260 minutes
        WHEN 23 THEN 42 * 60  -- 42 hours = 2520 minutes
        WHEN 24 THEN 29 * 60  -- 29 hours = 1740 minutes
        WHEN 25 THEN 54 * 60  -- 54 hours = 3240 minutes
        WHEN 26 THEN 29 * 60  -- 29 hours = 1740 minutes
        WHEN 27 THEN 30 * 60  -- 30 hours = 1800 minutes
        WHEN 28 THEN 35 * 60  -- 35 hours = 2100 minutes
        WHEN 29 THEN 27 * 60  -- 27 hours = 1620 minutes
        WHEN 30 THEN 27 * 60  -- 27 hours = 1620 minutes
        WHEN 31 THEN 17 * 60  -- 17 hours = 1020 minutes
        WHEN 32 THEN 13 * 60  -- 13 hours = 780 minutes
        WHEN 33 THEN 19 * 60  -- 19 hours = 1140 minutes
        WHEN 34 THEN 38 * 60  -- 38 hours = 2280 minutes
        WHEN 35 THEN 26 * 60  -- 26 hours = 1560 minutes
        WHEN 36 THEN 22 * 60  -- 22 hours = 1320 minutes
        WHEN 37 THEN 12 * 60  -- 12 hours = 720 minutes
        WHEN 38 THEN 16 * 60  -- 16 hours = 960 minutes
        WHEN 39 THEN 22 * 60  -- 22 hours = 1320 minutes
        WHEN 40 THEN 24 * 60  -- 24 hours = 1440 minutes
    END,
    NOW() + e.experiment_number * INTERVAL '1 day' + 
    CASE e.experiment_number
        WHEN 1 THEN 27 * 60 * INTERVAL '1 minute'  -- 27 hours = 1620 minutes
        WHEN 2 THEN 37 * 60 * INTERVAL '1 minute'  -- 37 hours = 2220 minutes
        WHEN 3 THEN 36 * 60 * INTERVAL '1 minute'  -- 36 hours = 2160 minutes
        WHEN 4 THEN 12 * 60 * INTERVAL '1 minute'  -- 12 hours = 720 minutes
        WHEN 5 THEN 34 * 60 * INTERVAL '1 minute'  -- 34 hours = 2040 minutes
        WHEN 6 THEN 18 * 60 * INTERVAL '1 minute'  -- 18 hours = 1080 minutes
        WHEN 7 THEN 14 * 60 * INTERVAL '1 minute'  -- 14 hours = 840 minutes
        WHEN 8 THEN 18 * 60 * INTERVAL '1 minute'  -- 18 hours = 1080 minutes
        WHEN 9 THEN 11 * 60 * INTERVAL '1 minute'  -- 11 hours = 660 minutes
        WHEN 10 THEN 33 * 60 * INTERVAL '1 minute'  -- 33 hours = 1980 minutes
        WHEN 11 THEN 23 * 60 * INTERVAL '1 minute'  -- 23 hours = 1380 minutes
        WHEN 12 THEN 37 * 60 * INTERVAL '1 minute'  -- 37 hours = 2220 minutes
        WHEN 13 THEN 15 * 60 * INTERVAL '1 minute'  -- 15 hours = 900 minutes
        WHEN 14 THEN 24 * 60 * INTERVAL '1 minute'  -- 24 hours = 1440 minutes
        WHEN 15 THEN 36 * 60 * INTERVAL '1 minute'  -- 36 hours = 2160 minutes
        WHEN 16 THEN 32 * 60 * INTERVAL '1 minute'  -- 32 hours = 1920 minutes
        WHEN 17 THEN 28 * 60 * INTERVAL '1 minute'  -- 28 hours = 1680 minutes
        WHEN 18 THEN 31 * 60 * INTERVAL '1 minute'  -- 31 hours = 1860 minutes
        WHEN 19 THEN 20 * 60 * INTERVAL '1 minute'  -- 20 hours = 1200 minutes
        WHEN 20 THEN 10 * 60 * INTERVAL '1 minute'  -- 10 hours = 600 minutes
        WHEN 21 THEN 16 * 60 * INTERVAL '1 minute'  -- 16 hours = 960 minutes
        WHEN 22 THEN 21 * 60 * INTERVAL '1 minute'  -- 21 hours = 1260 minutes
        WHEN 23 THEN 42 * 60 * INTERVAL '1 minute'  -- 42 hours = 2520 minutes
        WHEN 24 THEN 29 * 60 * INTERVAL '1 minute'  -- 29 hours = 1740 minutes
        WHEN 25 THEN 54 * 60 * INTERVAL '1 minute'  -- 54 hours = 3240 minutes
        WHEN 26 THEN 29 * 60 * INTERVAL '1 minute'  -- 29 hours = 1740 minutes
        WHEN 27 THEN 30 * 60 * INTERVAL '1 minute'  -- 30 hours = 1800 minutes
        WHEN 28 THEN 35 * 60 * INTERVAL '1 minute'  -- 35 hours = 2100 minutes
        WHEN 29 THEN 27 * 60 * INTERVAL '1 minute'  -- 27 hours = 1620 minutes
        WHEN 30 THEN 27 * 60 * INTERVAL '1 minute'  -- 27 hours = 1620 minutes
        WHEN 31 THEN 17 * 60 * INTERVAL '1 minute'  -- 17 hours = 1020 minutes
        WHEN 32 THEN 13 * 60 * INTERVAL '1 minute'  -- 13 hours = 780 minutes
        WHEN 33 THEN 19 * 60 * INTERVAL '1 minute'  -- 19 hours = 1140 minutes
        WHEN 34 THEN 38 * 60 * INTERVAL '1 minute'  -- 38 hours = 2280 minutes
        WHEN 35 THEN 26 * 60 * INTERVAL '1 minute'  -- 26 hours = 1560 minutes
        WHEN 36 THEN 22 * 60 * INTERVAL '1 minute'  -- 22 hours = 1320 minutes
        WHEN 37 THEN 12 * 60 * INTERVAL '1 minute'  -- 12 hours = 720 minutes
        WHEN 38 THEN 16 * 60 * INTERVAL '1 minute'  -- 16 hours = 960 minutes
        WHEN 39 THEN 22 * 60 * INTERVAL '1 minute'  -- 22 hours = 1320 minutes
        WHEN 40 THEN 24 * 60 * INTERVAL '1 minute'  -- 24 hours = 1440 minutes
    END,
    e.created_by
FROM public.experiments e
WHERE e.experiment_number BETWEEN 1 AND 40
AND e.phase_id = (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments')
ON CONFLICT DO NOTHING;

-- =============================================
-- CREATE AIRDRYING PHASE RECORDS FOR MEYER EXPERIMENTS
-- =============================================

-- Create airdrying records for Meyer experiments (1-40) with data from CSV
INSERT INTO public.airdrying (
    experiment_id,
    scheduled_start_time,
    duration_minutes,
    scheduled_end_time,
    created_by
)
SELECT 
    e.id,
    NOW() + e.experiment_number * INTERVAL '1 day' + INTERVAL '2 days', -- Start 2 days after soaking
    CASE e.experiment_number
        WHEN 1 THEN 28  -- 28 minutes
        WHEN 2 THEN 17  -- 17 minutes
        WHEN 3 THEN 50  -- 50 minutes
        WHEN 4 THEN 30  -- 30 minutes
        WHEN 5 THEN 19  -- 19 minutes
        WHEN 6 THEN 40  -- 40 minutes
        WHEN 7 THEN 59  -- 59 minutes
        WHEN 8 THEN 32  -- 32 minutes
        WHEN 9 THEN 31  -- 31 minutes
        WHEN 10 THEN 12  -- 12 minutes
        WHEN 11 THEN 36  -- 36 minutes
        WHEN 12 THEN 35  -- 35 minutes
        WHEN 13 THEN 15  -- 15 minutes
        WHEN 14 THEN 22  -- 22 minutes
        WHEN 15 THEN 15  -- 15 minutes
        WHEN 16 THEN 48  -- 48 minutes
        WHEN 17 THEN 38  -- 38 minutes
        WHEN 18 THEN 51  -- 51 minutes
        WHEN 19 THEN 57  -- 57 minutes
        WHEN 20 THEN 27  -- 27 minutes
        WHEN 21 THEN 43  -- 43 minutes
        WHEN 22 THEN 42  -- 42 minutes
        WHEN 23 THEN 21  -- 21 minutes
        WHEN 24 THEN 46  -- 46 minutes
        WHEN 25 THEN 54  -- 54 minutes
        WHEN 26 THEN 54  -- 54 minutes
        WHEN 27 THEN 48  -- 48 minutes
        WHEN 28 THEN 53  -- 53 minutes
        WHEN 29 THEN 39  -- 39 minutes
        WHEN 30 THEN 38  -- 38 minutes
        WHEN 31 THEN 25  -- 25 minutes
        WHEN 32 THEN 22  -- 22 minutes
        WHEN 33 THEN 11  -- 11 minutes
        WHEN 34 THEN 32  -- 32 minutes
        WHEN 35 THEN 18  -- 18 minutes
        WHEN 36 THEN 52  -- 52 minutes
        WHEN 37 THEN 56  -- 56 minutes
        WHEN 38 THEN 45  -- 45 minutes
        WHEN 39 THEN 25  -- 25 minutes
        WHEN 40 THEN 13  -- 13 minutes
    END,
    NOW() + e.experiment_number * INTERVAL '1 day' + INTERVAL '2 days' + 
    CASE e.experiment_number
        WHEN 1 THEN 28 * INTERVAL '1 minute'  -- 28 minutes
        WHEN 2 THEN 17 * INTERVAL '1 minute'  -- 17 minutes
        WHEN 3 THEN 50 * INTERVAL '1 minute'  -- 50 minutes
        WHEN 4 THEN 30 * INTERVAL '1 minute'  -- 30 minutes
        WHEN 5 THEN 19 * INTERVAL '1 minute'  -- 19 minutes
        WHEN 6 THEN 40 * INTERVAL '1 minute'  -- 40 minutes
        WHEN 7 THEN 59 * INTERVAL '1 minute'  -- 59 minutes
        WHEN 8 THEN 32 * INTERVAL '1 minute'  -- 32 minutes
        WHEN 9 THEN 31 * INTERVAL '1 minute'  -- 31 minutes
        WHEN 10 THEN 12 * INTERVAL '1 minute'  -- 12 minutes
        WHEN 11 THEN 36 * INTERVAL '1 minute'  -- 36 minutes
        WHEN 12 THEN 35 * INTERVAL '1 minute'  -- 35 minutes
        WHEN 13 THEN 15 * INTERVAL '1 minute'  -- 15 minutes
        WHEN 14 THEN 22 * INTERVAL '1 minute'  -- 22 minutes
        WHEN 15 THEN 15 * INTERVAL '1 minute'  -- 15 minutes
        WHEN 16 THEN 48 * INTERVAL '1 minute'  -- 48 minutes
        WHEN 17 THEN 38 * INTERVAL '1 minute'  -- 38 minutes
        WHEN 18 THEN 51 * INTERVAL '1 minute'  -- 51 minutes
        WHEN 19 THEN 57 * INTERVAL '1 minute'  -- 57 minutes
        WHEN 20 THEN 27 * INTERVAL '1 minute'  -- 27 minutes
        WHEN 21 THEN 43 * INTERVAL '1 minute'  -- 43 minutes
        WHEN 22 THEN 42 * INTERVAL '1 minute'  -- 42 minutes
        WHEN 23 THEN 21 * INTERVAL '1 minute'  -- 21 minutes
        WHEN 24 THEN 46 * INTERVAL '1 minute'  -- 46 minutes
        WHEN 25 THEN 54 * INTERVAL '1 minute'  -- 54 minutes
        WHEN 26 THEN 54 * INTERVAL '1 minute'  -- 54 minutes
        WHEN 27 THEN 48 * INTERVAL '1 minute'  -- 48 minutes
        WHEN 28 THEN 53 * INTERVAL '1 minute'  -- 53 minutes
        WHEN 29 THEN 39 * INTERVAL '1 minute'  -- 39 minutes
        WHEN 30 THEN 38 * INTERVAL '1 minute'  -- 38 minutes
        WHEN 31 THEN 25 * INTERVAL '1 minute'  -- 25 minutes
        WHEN 32 THEN 22 * INTERVAL '1 minute'  -- 22 minutes
        WHEN 33 THEN 11 * INTERVAL '1 minute'  -- 11 minutes
        WHEN 34 THEN 32 * INTERVAL '1 minute'  -- 32 minutes
        WHEN 35 THEN 18 * INTERVAL '1 minute'  -- 18 minutes
        WHEN 36 THEN 52 * INTERVAL '1 minute'  -- 52 minutes
        WHEN 37 THEN 56 * INTERVAL '1 minute'  -- 56 minutes
        WHEN 38 THEN 45 * INTERVAL '1 minute'  -- 45 minutes
        WHEN 39 THEN 25 * INTERVAL '1 minute'  -- 25 minutes
        WHEN 40 THEN 13 * INTERVAL '1 minute'  -- 13 minutes
    END,
    e.created_by
FROM public.experiments e
WHERE e.experiment_number BETWEEN 1 AND 40
AND e.phase_id = (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments')
ON CONFLICT DO NOTHING;

-- =============================================
-- CREATE CRACKING PHASE RECORDS FOR MEYER EXPERIMENTS
-- =============================================

-- Create cracking records for Meyer experiments (1-40)
INSERT INTO public.cracking (
    experiment_id,
    machine_type_id,
    scheduled_start_time,
    created_by
)
SELECT 
    e.id,
    (SELECT id FROM public.machine_types WHERE name = 'Meyer Cracker'),
    NOW() + e.experiment_number * INTERVAL '1 day' + INTERVAL '3 days', -- Start 3 days after soaking
    e.created_by
FROM public.experiments e
WHERE e.experiment_number BETWEEN 1 AND 40
AND e.phase_id = (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments')
ON CONFLICT DO NOTHING;

-- =============================================
-- CREATE MEYER CRACKER PARAMETERS FOR MEYER EXPERIMENTS
-- =============================================

-- Create Meyer cracker parameters for Meyer experiments (1-40) with data from CSV
INSERT INTO public.meyer_cracker_parameters (
    cracking_id,
    motor_speed_hz,
    jig_displacement_inches,
    spring_stiffness_nm
)
SELECT 
    c.id,
    CASE e.experiment_number
        WHEN 1 THEN 33.0
        WHEN 2 THEN 30.0
        WHEN 3 THEN 47.0
        WHEN 4 THEN 42.0
        WHEN 5 THEN 53.0
        WHEN 6 THEN 37.0
        WHEN 7 THEN 40.0
        WHEN 8 THEN 39.0
        WHEN 9 THEN 49.0
        WHEN 10 THEN 47.0
        WHEN 11 THEN 52.0
        WHEN 12 THEN 59.0
        WHEN 13 THEN 41.0
        WHEN 14 THEN 46.0
        WHEN 15 THEN 50.0
        WHEN 16 THEN 36.0
        WHEN 17 THEN 33.0
        WHEN 18 THEN 35.0
        WHEN 19 THEN 55.0
        WHEN 20 THEN 44.0
        WHEN 21 THEN 37.0
        WHEN 22 THEN 56.0
        WHEN 23 THEN 30.0
        WHEN 24 THEN 60.0
        WHEN 25 THEN 41.0
        WHEN 26 THEN 55.0
        WHEN 27 THEN 39.0
        WHEN 28 THEN 34.0
        WHEN 29 THEN 57.0
        WHEN 30 THEN 45.0
        WHEN 31 THEN 52.0
        WHEN 32 THEN 51.0
        WHEN 33 THEN 36.0
        WHEN 34 THEN 44.0
        WHEN 35 THEN 58.0
        WHEN 36 THEN 32.0
        WHEN 37 THEN 43.0
        WHEN 38 THEN 60.0
        WHEN 39 THEN 54.0
        WHEN 40 THEN 48.0
    END,
    CASE e.experiment_number
        WHEN 1 THEN -0.307
        WHEN 2 THEN -0.311
        WHEN 3 THEN -0.291
        WHEN 4 THEN -0.314
        WHEN 5 THEN -0.302
        WHEN 6 THEN -0.301
        WHEN 7 THEN -0.286
        WHEN 8 THEN -0.309
        WHEN 9 THEN -0.299
        WHEN 10 THEN -0.295
        WHEN 11 THEN -0.302
        WHEN 12 THEN -0.299
        WHEN 13 THEN -0.312
        WHEN 14 THEN -0.303
        WHEN 15 THEN -0.308
        WHEN 16 THEN -0.306
        WHEN 17 THEN -0.308
        WHEN 18 THEN -0.311
        WHEN 19 THEN -0.304
        WHEN 20 THEN -0.313
        WHEN 21 THEN -0.294
        WHEN 22 THEN -0.310
        WHEN 23 THEN -0.292
        WHEN 24 THEN -0.294
        WHEN 25 THEN -0.306
        WHEN 26 THEN -0.296
        WHEN 27 THEN -0.293
        WHEN 28 THEN -0.285
        WHEN 29 THEN -0.291
        WHEN 30 THEN -0.296
        WHEN 31 THEN -0.297
        WHEN 32 THEN -0.288
        WHEN 33 THEN -0.290
        WHEN 34 THEN -0.315
        WHEN 35 THEN -0.289
        WHEN 36 THEN -0.288
        WHEN 37 THEN -0.287
        WHEN 38 THEN -0.298
        WHEN 39 THEN -0.301
        WHEN 40 THEN -0.305
    END,
    CASE e.experiment_number
        WHEN 1 THEN 1800.0
        WHEN 2 THEN 2000.0
        WHEN 3 THEN 1800.0
        WHEN 4 THEN 2000.0
        WHEN 5 THEN 1800.0
        WHEN 6 THEN 2200.0
        WHEN 7 THEN 2000.0
        WHEN 8 THEN 1800.0
        WHEN 9 THEN 2200.0
        WHEN 10 THEN 2000.0
        WHEN 11 THEN 2000.0
        WHEN 12 THEN 1800.0
        WHEN 13 THEN 2000.0
        WHEN 14 THEN 1800.0
        WHEN 15 THEN 1800.0
        WHEN 16 THEN 2200.0
        WHEN 17 THEN 2200.0
        WHEN 18 THEN 1800.0
        WHEN 19 THEN 2000.0
        WHEN 20 THEN 2200.0
        WHEN 21 THEN 2000.0
        WHEN 22 THEN 2200.0
        WHEN 23 THEN 2200.0
        WHEN 24 THEN 2200.0
        WHEN 25 THEN 2000.0
        WHEN 26 THEN 1800.0
        WHEN 27 THEN 2200.0
        WHEN 28 THEN 2200.0
        WHEN 29 THEN 1800.0
        WHEN 30 THEN 2200.0
        WHEN 31 THEN 1800.0
        WHEN 32 THEN 2200.0
        WHEN 33 THEN 2000.0
        WHEN 34 THEN 1800.0
        WHEN 35 THEN 1800.0
        WHEN 36 THEN 1800.0
        WHEN 37 THEN 2200.0
        WHEN 38 THEN 2200.0
        WHEN 39 THEN 2000.0
        WHEN 40 THEN 2000.0
    END
FROM public.experiments e
JOIN public.cracking c ON c.experiment_id = e.id
WHERE e.experiment_number BETWEEN 1 AND 40
AND e.phase_id = (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments')
ON CONFLICT DO NOTHING;

-- =============================================
-- CREATE EXPERIMENT REPETITIONS FOR MEYER EXPERIMENTS
-- =============================================

-- Create experiment repetitions for Meyer experiments
-- Each experiment needs only 1 repetition
INSERT INTO public.experiment_repetitions (
    experiment_id,
    repetition_number,
    completion_status,
    created_by
)
SELECT 
    e.id,
    1,
    false,
    e.created_by
FROM public.experiments e
WHERE e.experiment_number BETWEEN 1 AND 40
AND e.phase_id = (SELECT id FROM public.experiment_phases WHERE name = 'Post Workshop Meyer Experiments')
ON CONFLICT DO NOTHING;
