//! The forum content itself: which threads exist, who posts in them, and what //! they say. Each category's table is a sibling const, so the loop that writes //! it stays readable next to the other three. mod discussion; mod general; mod mixing; mod sound_design; use super::rows::{seed_post, seed_thread}; use super::users::SeedUser; use sqlx::PgPool; use uuid::Uuid; /// 35 threads in Music/General, enough for 2 pages. pub(super) async fn seed_music_general(pool: &PgPool, category_id: Uuid, users: &[SeedUser]) { let threads = general::THREADS; // Pinned welcome thread let welcome_id = seed_thread(pool, category_id, users[0].id, threads[0].0, true, false).await; seed_post(pool, welcome_id, users[0].id, threads[0].1).await; for (i, reply) in threads[0].2.iter().enumerate() { seed_post(pool, welcome_id, users[(i + 2) % users.len()].id, reply).await; } // Remaining threads, one with lots of replies for post pagination for (idx, (title, body, replies)) in threads.iter().enumerate().skip(1) { let author = &users[(idx + 1) % users.len()]; let thread_id = seed_thread(pool, category_id, author.id, title, false, false).await; seed_post(pool, thread_id, author.id, body).await; for (i, reply) in replies.iter().enumerate() { let replier = &users[(idx + i + 3) % users.len()]; seed_post(pool, thread_id, replier.id, reply).await; } // Thread #1 (DAW thread): add 55 extra posts to test post pagination (50/page) if idx == 1 { seed_long_discussion(pool, thread_id, users).await; } } } /// 15 threads in Mixing & Mastering. pub(super) async fn seed_music_mixing(pool: &PgPool, category_id: Uuid, users: &[SeedUser]) { let threads = mixing::THREADS; for (idx, (title, body, replies)) in threads.iter().enumerate() { let author = &users[(idx + 2) % users.len()]; let thread_id = seed_thread(pool, category_id, author.id, title, false, false).await; seed_post(pool, thread_id, author.id, body).await; for (i, reply) in replies.iter().enumerate() { let replier = &users[(idx + i + 4) % users.len()]; seed_post(pool, thread_id, replier.id, reply).await; } } } /// 15 threads in Sound Design. pub(super) async fn seed_music_sound_design(pool: &PgPool, category_id: Uuid, users: &[SeedUser]) { let threads = sound_design::THREADS; for (idx, (title, body, replies)) in threads.iter().enumerate() { let author = &users[(idx + 5) % users.len()]; let thread_id = seed_thread(pool, category_id, author.id, title, false, false).await; seed_post(pool, thread_id, author.id, body).await; for (i, reply) in replies.iter().enumerate() { let replier = &users[(idx + i + 6) % users.len()]; seed_post(pool, thread_id, replier.id, reply).await; } } } /// Add 55 extra posts to a thread to test post pagination (50 posts/page). pub(super) async fn seed_long_discussion(pool: &PgPool, thread_id: Uuid, users: &[SeedUser]) { let posts = discussion::POSTS; for (i, body) in posts.iter().enumerate() { let author = &users[(i + 4) % users.len()]; seed_post(pool, thread_id, author.id, body).await; } }