-- CREATE SETUP

BEGIN;

    INSERT INTO doki8902.post_category(name) VALUES
        ('Technology'),
        ('Food'),
        ('Games'),
        ('Reading'),
        ('Movies'),
        ('Sports'),
        ('Travel');

COMMIT;

-- CREATE USERS
    
BEGIN;

    INSERT INTO doki8902.user(username, password) VALUES
        ('Alice', 'pass123'),
        ('Bob', 'qwerty'),
        ('Charlie', 'abc456'),
        ('David', 'secret'),
        ('Eve', 'p@ssw0rd'),
        ('Frank', 'admin123'),
        ('Grace', 'letmein'),
        ('Henry', 'changeme'),
        ('Isabel', 'ilovecats'),
        ('Jack', 'welcome'),
        ('BotAccount', 'qwertyasdf');

    INSERT INTO doki8902.user(username, password, access) VALUES ('admin', '$argon2id$v=19$m=65536,t=4,p=1$QNRzi0vaVyjR/AszHyJF9Q$+2rRyTHHMIYjYCRSZEpjRGWLjWWl1Jval8JH/l2ArymxEbSjctGWMT4X0neqVeN9yC32LO9utmH9WHr0gJXpQQ', 'elevated');

    INSERT INTO doki8902.user_session(user_id) VALUES (1), (2), (3), (5), (5), (6), (7), (8), (9), (11);

COMMIT;

-- NORMAL USE

BEGIN;

    SELECT doki8902.func_log_user_restrict(4, 'Excessive spamming');
    SELECT doki8902.func_log_user_restrict(5, 'Inappropriate content');

    INSERT INTO doki8902.message_post(author_id, category_id, name, latest_content) VALUES
        (4, 1, 'Best practices for data security', 'It''s crucial to keep your software updated to avoid security breaches.'),
        (1, 2, 'Grilling tips for beginners', 'Always preheat your grill for at least 15 minutes.'),
        (7, 3, 'Upcoming RPG games 2024', 'Anyone excited about the new Dragon Quest release?'),
        (2, 4, 'Book recommendations for historical fiction', 'I just finished "The Nightingale" and loved it!'),
        (10, 5, 'Which director makes the best thrillers?', 'I think Christopher Nolan does a great job with complex narratives.'),
        (3, 6, 'Is tennis the most physically demanding sport?', 'The agility and stamina required are intense.'),
        (5, 7, 'Budget-friendly European destinations', 'Portugal is quite affordable and beautiful.'),
        (6, 1, 'The future of quantum computing', 'Quantum computers could revolutionize how we process data.'),
        (8, 2, 'What''s your favorite type of cheese?', 'I can never get enough of Gouda!'),
        (9, 5, 'Horror movies that are actually scary', 'The Conjuring series still gives me chills.');

    INSERT INTO doki8902.message_comment(author_id, post_id, latest_content, parent_comment_id) VALUES
        (9, 1, 'Absolutely! Regular updates are a must.', NULL),
        (8, 2, 'Thanks for the tip! Any specific grills you recommend?', NULL),
        (2, 2, 'Charcoal grills give the best flavor in my opinion.', NULL),
        (7, 3, 'I heard it''s coming out next fall.', NULL),
        (3, 3, 'Can''t wait for it, it sounds amazing!', NULL),
        (8, 4, 'I love historical fiction too, any other suggestions?', NULL),
        (1, 5, 'Agreed, Nolan is a mastermind.', NULL),
        (3, 5, 'What about Alfred Hitchcock?', NULL),
        (5, 6, 'I think boxing might compete for that title.', NULL),
        (7, 7, 'Don''t forget about Greece, especially during off-peak seasons!', NULL),
        (1, 8, 'How soon do you think we''ll see practical applications?', NULL),
        (7, 9, 'Cheddar is great for cooking but nothing beats Brie for snacking.', NULL),
        (9, 9, 'Gouda is indeed delicious!', NULL),
        (4, 10, 'Those films are great, have you seen "Insidious" as well?', NULL);

    INSERT INTO doki8902.message_comment(author_id, post_id, latest_content, parent_comment_id) VALUES
        (4, 1, 'That''s a good point. Do you recommend any specific antivirus software?', 11),
        (9, 2, 'I''ve been looking at Weber grills, heard they''re good.', 12),
        (3, 2, 'Yes, but I think gas grills are easier for beginners.', 13),
        (7, 3, 'I hope they add more customization options.', 15),
        (2, 4, 'You should check out "Pillars of the Earth" by Ken Follett.', 16),
        (6, 5, 'True, but don''t forget about M. Night Shyamalan.', 18),
        (2, 6, 'Agree on boxing, but MMA seems tougher.', 19),
        (6, 7, 'Also Bulgaria in the autumn is surprisingly beautiful.', 20),
        (8, 9, 'Totally agree on Brie, especially with a good wine.', 22),
        (9, 10, 'Insidious was good but it doesn''t top The Conjuring for me.', 24);

    INSERT INTO doki8902.message_vote(message_id, user_id, vote) VALUES
        (1, 5, 1),
        (2, 4, 1),
        (3, 6, -1),
        (4, 3, 1),
        (5, 8, 1),
        (8, 2, 1),
        (11, 1, 1),
        (12, 10, -1),
        (14, 6, 1),
        (15, 4, 1),
        (17, 4, 1),
        (19, 2, 1),
        (20, 1, 1),
        (22, 3, 1),
        (23, 5, 1),
        (25, 7, 1),
        (28, 8, 1),
        (31, 6, -1),
        (32, 9, 1),
        (34, 10, 1),
        -- Adding 5 dislikes to message 10
        (10, 2, -1),
        (10, 6, -1),
        (10, 7, -1),
        (10, 8, -1),
        (10, 10, -1),
        -- Adding 5 dislikes to message 11
        (11, 2, -1),
        (11, 6, -1),
        (11, 7, -1),
        (11, 8, -1),
        (11, 3, -1);

COMMIT;

-- ACCEPT ALL CURRENT CONTENT

SELECT doki8902.func_approve_all_pending_content();
