diff --git a/db/seeds.rb b/db/seeds.rb index 5caf729..2a24969 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,201 +1,495 @@ +# Real Project Data Seed File +# This file contains actual project data from ~/apps folder +# Last updated: January 2026 based on git history inspection + # Clear existing data puts "Clearing existing data..." Task.destroy_all Project.destroy_all -# Project data -projects_data = [ +puts "Creating real projects from ~/apps portfolio..." + +# ============================================================================= +# 🟒 RECENTLY ACTIVE (commits within last 2 months) +# ============================================================================= + +# 1. am - Affiliate Marketing Platform (NEW!) +am = Project.create!( + name: "am", + description: "Developer Tools Affiliate Marketing Platform. Rails 8 platform for performance-based affiliate marketing. Focus on developer tools, SaaS, APIs, hosting. Last active: 7 weeks ago." +) + +Task.create!([ { - name: "Website Redesign", - description: "Redesign the company website with modern UI/UX and improved accessibility" + project: am, + title: "Set up affiliate tracking system", + description: "Implement custom affiliate link tracking and attribution", + status: "in_progress", + priority: 1, + due_date: 14.days.from_now }, { - name: "Mobile App Development", - description: "Build a cross-platform mobile app for iOS and Android using React Native" + project: am, + title: "Content automation pipeline", + description: "Build automated content distribution for SEO", + status: "todo", + priority: 1, + due_date: 30.days.from_now }, { - name: "Marketing Campaign Q1", - description: "Launch comprehensive marketing campaign for Q1 2025" + project: am, + title: "Analytics dashboard", + description: "Create dashboard for tracking commissions and conversions", + status: "todo", + priority: 2, + due_date: 45.days.from_now + } +]) + +# 2. supap-front - SUPAP Frontend (7 weeks ago) +supap_front = Project.create!( + name: "supap-front", + description: "SUPAP (Sociedad Uruguaya de Psicoterapias Asistidas con PsicodΓ©licos) frontend. Next.js 14.2.25 + Tailwind v4. Animation system implemented. Last active: 7 weeks ago." +) + +Task.create!([ + { + project: supap_front, + title: "Merge branding assets branch", + description: "Complete and merge feat/update-branding-assets branch", + status: "in_progress", + priority: 1, + due_date: 7.days.from_now }, { - name: "API Modernization", - description: "Migrate legacy REST API to GraphQL and improve performance" + project: supap_front, + title: "Spanish content population", + description: "Populate all sections with Spanish content", + status: "todo", + priority: 1, + due_date: 21.days.from_now }, { - name: "Customer Portal", - description: "Build self-service customer portal with account management features" + project: supap_front, + title: "Accessibility audit", + description: "WCAG compliance check and fixes", + status: "todo", + priority: 2, + due_date: 30.days.from_now + } +]) + +# 3. supap-back - SUPAP Backend (8 weeks ago) +supap_back = Project.create!( + name: "supap-back", + description: "SUPAP backend API. Spring Boot + PostgreSQL + JWT. Currently on phase-6 branch. Last active: 8 weeks ago." +) + +Task.create!([ + { + project: supap_back, + title: "Complete phase-6", + description: "Finish and merge phase-6 branch work", + status: "in_progress", + priority: 1, + due_date: 10.days.from_now }, { - name: "Data Analytics Dashboard", - description: "Create real-time analytics dashboard for business metrics" + project: supap_back, + title: "JWT authentication", + description: "Configure Spring Security with JWT tokens", + status: "todo", + priority: 1, + due_date: 20.days.from_now }, { - name: "Infrastructure Upgrade", - description: "Upgrade cloud infrastructure and implement auto-scaling" + project: supap_back, + title: "Flyway migrations", + description: "Create initial database migration scripts", + status: "todo", + priority: 2, + due_date: 25.days.from_now + } +]) + +# 4. creaciones-del-mago - Artist Portfolio (7 weeks ago) +creaciones = Project.create!( + name: "creaciones-del-mago", + description: "Artist portfolio website. Next.js 15 canary + TailwindCSS. Recently fixed Next.js 15 compatibility. Last active: 7 weeks ago." +) + +Task.create!([ + { + project: creaciones, + title: "Stabilize Next.js 15", + description: "Move from canary to stable Next.js 15 release", + status: "todo", + priority: 2, + due_date: 14.days.from_now }, { - name: "Security Audit", - description: "Conduct comprehensive security audit and implement fixes" + project: creaciones, + title: "Performance optimization", + description: "Image optimization and Core Web Vitals improvements", + status: "todo", + priority: 2, + due_date: 21.days.from_now }, { - name: "Documentation Overhaul", - description: "Rewrite technical documentation and create video tutorials" + project: creaciones, + title: "Deploy to production", + description: "Final testing and production deployment", + status: "todo", + priority: 1, + due_date: 30.days.from_now + } +]) + +# 5. personal-site - Professional Portfolio (8 weeks ago) +personal_site = Project.create!( + name: "personal-site", + description: "Professional portfolio with crystal glass UI. Next.js (latest) + TypeScript + shadcn/ui. Theme support and performance optimization done. Last active: 8 weeks ago." +) + +Task.create!([ + { + project: personal_site, + title: "Anti-spam protection", + description: "Implement rate limiting + CAPTCHA for contact form", + status: "todo", + priority: 2, + due_date: 14.days.from_now }, { - name: "Employee Onboarding System", - description: "Build automated onboarding system for new hires" + project: personal_site, + title: "Update portfolio projects", + description: "Add recent projects to portfolio section", + status: "todo", + priority: 2, + due_date: 21.days.from_now } -] - -# Task templates with variety of titles and descriptions -task_templates = [ - # Design tasks - { title: "Create wireframes", description: "Design low-fidelity wireframes for user flow", category: :design }, - { title: "Design mockups", description: "Create high-fidelity mockups in Figma", category: :design }, - { title: "Build design system", description: "Establish design system with components and tokens", category: :design }, - { title: "Conduct user research", description: "Interview users and gather feedback", category: :design }, - { title: "Create prototypes", description: "Build interactive prototypes for testing", category: :design }, - - # Development tasks - { title: "Setup project structure", description: "Initialize project with required dependencies", category: :development }, - { title: "Implement authentication", description: "Add user authentication with OAuth2", category: :development }, - { title: "Build REST API endpoints", description: "Create RESTful API endpoints for core features", category: :development }, - { title: "Add database migrations", description: "Create and run database schema migrations", category: :development }, - { title: "Implement search functionality", description: "Add full-text search with Elasticsearch", category: :development }, - { title: "Write unit tests", description: "Add comprehensive unit test coverage", category: :development }, - { title: "Setup CI/CD pipeline", description: "Configure automated testing and deployment", category: :development }, - { title: "Optimize database queries", description: "Refactor slow queries and add indexes", category: :development }, - { title: "Add caching layer", description: "Implement Redis caching for performance", category: :development }, - { title: "Build admin dashboard", description: "Create admin interface for management", category: :development }, - - # Testing tasks - { title: "Write integration tests", description: "Add end-to-end integration test suite", category: :testing }, - { title: "Perform load testing", description: "Test application under high load conditions", category: :testing }, - { title: "Conduct security testing", description: "Run penetration tests and security scans", category: :testing }, - { title: "UAT with stakeholders", description: "User acceptance testing with business team", category: :testing }, - - # DevOps tasks - { title: "Setup monitoring", description: "Configure APM and error tracking", category: :devops }, - { title: "Implement logging", description: "Add structured logging with ELK stack", category: :devops }, - { title: "Configure backups", description: "Setup automated database backups", category: :devops }, - { title: "Setup staging environment", description: "Create staging environment matching production", category: :devops }, - { title: "Implement auto-scaling", description: "Configure horizontal pod autoscaling", category: :devops }, - - # Documentation tasks - { title: "Write API documentation", description: "Document all API endpoints with examples", category: :documentation }, - { title: "Create user guides", description: "Write comprehensive user documentation", category: :documentation }, - { title: "Record demo videos", description: "Create video tutorials for key features", category: :documentation }, - { title: "Update README", description: "Update project README with latest information", category: :documentation }, - - # Management tasks - { title: "Sprint planning", description: "Plan upcoming sprint with team", category: :management }, - { title: "Code review", description: "Review pull requests from team members", category: :management }, - { title: "Stakeholder meeting", description: "Present progress to stakeholders", category: :management }, - { title: "Team retrospective", description: "Conduct sprint retrospective meeting", category: :management }, - - # Bug fixes - { title: "Fix login bug", description: "Resolve issue with login timeout", category: :bugfix }, - { title: "Fix payment processing", description: "Debug payment gateway integration issue", category: :bugfix }, - { title: "Fix mobile responsiveness", description: "Resolve layout issues on mobile devices", category: :bugfix }, - { title: "Fix data validation", description: "Add missing validation rules", category: :bugfix }, - { title: "Fix email notifications", description: "Debug email delivery failures", category: :bugfix } -] - -# Status distribution (realistic project distribution) -# 50% todo, 30% in_progress, 20% done -def weighted_status - rand_num = rand - if rand_num < 0.5 - "todo" - elsif rand_num < 0.8 - "in_progress" - else - "done" - end -end +]) -# Create projects -puts "Creating projects..." -projects = projects_data.map do |project_data| - Project.create!(project_data) -end +# 6. ai-assistant-development-kit (7 weeks ago) +aidk = Project.create!( + name: "ai-assistant-development-kit", + description: "Collection of boilerplate projects: Rails, Spring Boot, Next.js, Elixir, Flutter, Playwright. Recently added Java Spring Boot boilerplate. Last active: 7 weeks ago." +) -# Create 100 tasks distributed across projects -puts "Creating tasks..." -task_count = 0 -target_tasks = 100 - -projects.each_with_index do |project, project_index| - # Distribute tasks unevenly (some projects have more tasks) - tasks_for_project = case project_index - when 0..2 then 15 # First 3 projects get 15 tasks each - when 3..5 then 10 # Next 3 projects get 10 tasks each - when 6..8 then 7 # Next 3 projects get 7 tasks each - else 4 # Last project gets 4 tasks - end +Task.create!([ + { + project: aidk, + title: "Update Rails boilerplate to 8.0", + description: "Upgrade Rails template to Rails 8.0 with Solid Queue", + status: "todo", + priority: 3, + due_date: nil + }, + { + project: aidk, + title: "Document all boilerplates", + description: "Create comprehensive README for each boilerplate", + status: "todo", + priority: 3, + due_date: nil + } +]) - tasks_for_project.times do |i| - break if task_count >= target_tasks - - # Select a random task template - template = task_templates.sample - - # Determine status based on weights - status = weighted_status - - # Priority (1-5, with bias toward 2-3) - priority = [ 1, 2, 2, 3, 3, 3, 4, 4, 5 ].sample - - # Due date logic - due_date = if rand < 0.1 # 10% have no due date - nil - elsif rand < 0.2 # 20% are overdue - rand(1..14).days.ago - elsif rand < 0.5 # 30% are due soon (next 7 days) - rand(1..7).days.from_now - else # 40% are due later - rand(8..30).days.from_now - end - - # Adjust status for completed tasks (they shouldn't be overdue) - if status == "done" && due_date && due_date < Date.today - due_date = rand(1..30).days.ago - end - - Task.create!( - project: project, - title: "#{template[:title]} - Phase #{i + 1}", - description: template[:description], - status: status, - priority: priority, - due_date: due_date - ) - - task_count += 1 - end -end +# ============================================================================= +# 🟑 PAUSED PROJECTS (3-5 months inactive) +# ============================================================================= + +# 7. maicemita-site - E-commerce (4 months ago) +maicemita = Project.create!( + name: "maicemita-site", + description: "E-commerce for homemade alfajores. Next.js 15 + TypeScript + TailwindCSS. Phase 1 refactoring complete. PAUSED - Last active: 4 months ago." +) + +Task.create!([ + { + project: maicemita, + title: "Payment integration", + description: "Integrate Stripe/PayPal for payments", + status: "todo", + priority: 1, + due_date: nil + }, + { + project: maicemita, + title: "Order management system", + description: "Build admin dashboard for orders", + status: "todo", + priority: 2, + due_date: nil + } +]) + +# 8. avent-properties - Property Platform (5 months ago) +avent = Project.create!( + name: "avent-properties", + description: "Property booking platform with tour reservations. Next.js 15.2.4 + Apollo + Supabase. Tour system complete. PAUSED - Last active: 5 months ago." +) + +Task.create!([ + { + project: avent, + title: "Stripe payment integration", + description: "Add payment processing for tour deposits", + status: "todo", + priority: 1, + due_date: nil + }, + { + project: avent, + title: "Email notifications", + description: "Automated booking confirmations", + status: "todo", + priority: 2, + due_date: nil + } +]) + +# 9. train-uy - Train Visualization (5 months ago) +train_uy = Project.create!( + name: "train-uy", + description: "Train route visualization for Uruguay. Next.js 15.2.4 + Supabase. Fixed RSC webpack issues. PAUSED - Last active: 5 months ago." +) + +Task.create!([ + { + project: train_uy, + title: "Database schema design", + description: "Define schema for routes, stations, schedules", + status: "todo", + priority: 1, + due_date: nil + }, + { + project: train_uy, + title: "Map visualization", + description: "Implement interactive route map", + status: "todo", + priority: 2, + due_date: nil + } +]) -# Summary statistics -puts "\n" + "=" * 50 -puts "Seed data created successfully!" -puts "=" * 50 -puts "Projects: #{Project.count}" -puts "Tasks: #{Task.count}" -puts "\nTask Breakdown:" -puts " Todo: #{Task.where(status: 'todo').count}" -puts " In Progress: #{Task.where(status: 'in_progress').count}" -puts " Done: #{Task.where(status: 'done').count}" -puts "\nOverdue tasks: #{Task.overdue.count}" -puts "\nPriority Distribution:" +# 10. pomodoro - Flutter Timer (5 months ago) +pomodoro = Project.create!( + name: "pomodoro", + description: "Flutter Pomodoro timer app for iOS/Android. MVP complete. PAUSED - Last active: 5 months ago." +) + +Task.create!([ + { + project: pomodoro, + title: "App store submission", + description: "Submit to iOS App Store and Google Play", + status: "todo", + priority: 1, + due_date: nil + }, + { + project: pomodoro, + title: "Marketing assets", + description: "Create app icons and store screenshots", + status: "todo", + priority: 2, + due_date: nil + } +]) + +# 11. linear-clone - Project Management (5 months ago) +linear_clone = Project.create!( + name: "linear-clone", + description: "Linear PM tool clone. Phoenix/Elixir + GraphQL + Next.js frontend. Added docs and setup guides. PAUSED - Last active: 5 months ago." +) + +Task.create!([ + { + project: linear_clone, + title: "Upgrade Phoenix to 1.7", + description: "Follow Phoenix 1.7 migration guide", + status: "todo", + priority: 2, + due_date: nil + }, + { + project: linear_clone, + title: "Complete GraphQL API", + description: "Finish backend Absinthe GraphQL implementation", + status: "todo", + priority: 2, + due_date: nil + } +]) + +# 12. trees-software-landing (4 months ago) +trees = Project.create!( + name: "trees-software-landing", + description: "Trees Software company landing page. Next.js 14.2.25 + TypeScript + TailwindCSS. Docs and AI tooling added. PAUSED - Last active: 4 months ago." +) + +Task.create!([ + { + project: trees, + title: "UI polish", + description: "Final UI refinements and animations", + status: "todo", + priority: 2, + due_date: nil + }, + { + project: trees, + title: "Production deployment", + description: "Deploy to production environment", + status: "todo", + priority: 1, + due_date: nil + } +]) + +# ============================================================================= +# πŸ”΅ EARLY STAGE / MINIMAL ACTIVITY +# ============================================================================= + +# 13. aldea-infinita - Community Platform (no git history) +aldea = Project.create!( + name: "aldea-infinita", + description: "Community platform project. Next.js 16 + Supabase (planned). Early stage - just initialized." +) + +Task.create!([ + { + project: aldea, + title: "Initial project setup", + description: "Configure project structure and dependencies", + status: "todo", + priority: 2, + due_date: nil + }, + { + project: aldea, + title: "Define MVP scope", + description: "Document core features for MVP", + status: "todo", + priority: 2, + due_date: nil + } +]) + +# 14. ML-props-scraper - Property Scraper +scrappers = Project.create!( + name: "ML-props-scraper", + description: "Web scraper for ML properties using Playwright. Maintenance mode." +) + +Task.create!([ + { + project: scrappers, + title: "Update selectors", + description: "Update CSS selectors if site structure changed", + status: "todo", + priority: 4, + due_date: nil + } +]) + +# ============================================================================= +# 🟒 THIS PROJECT - task-tracker +# ============================================================================= + +task_tracker = Project.create!( + name: "task-tracker", + description: "Rails 8 task management app. CRUD, filtering, sorting, JSON API, Solid Queue. Docker deployment added. THIS PROJECT - actively maintained." +) + +Task.create!([ + { + project: task_tracker, + title: "Core features complete", + description: "All assignment requirements met: models, CRUD, filtering, API, tests", + status: "done", + priority: 1, + due_date: 4.days.ago + }, + { + project: task_tracker, + title: "Docker deployment", + description: "Local Docker deployment with docker-compose", + status: "done", + priority: 1, + due_date: Date.today + }, + { + project: task_tracker, + title: "Render deployment fix", + description: "Fix preDeployCommand for Render.com", + status: "done", + priority: 1, + due_date: Date.today + }, + { + project: task_tracker, + title: "Import real project data", + description: "Populate with actual portfolio projects from ~/apps", + status: "in_progress", + priority: 1, + due_date: Date.today + } +]) + +# ============================================================================= +# SUMMARY STATISTICS +# ============================================================================= + +puts "\n" + "=" * 70 +puts "πŸŽ‰ REAL PROJECT DATA IMPORTED SUCCESSFULLY!" +puts "=" * 70 +puts "πŸ“Š Statistics:" +puts " Projects: #{Project.count}" +puts " Tasks: #{Task.count}" +puts "\nπŸ“‹ Task Breakdown:" +puts " βœ… Done: #{Task.where(status: 'done').count}" +puts " πŸ”„ In Progress: #{Task.where(status: 'in_progress').count}" +puts " πŸ“ Todo: #{Task.where(status: 'todo').count}" +puts "\n⚠️ Overdue Tasks: #{Task.overdue.count}" +puts "\n🎯 Priority Distribution:" (1..5).each do |priority| count = Task.where(priority: priority).count - puts " Priority #{priority}: #{count}" + priority_label = case priority + when 1 then "πŸ”΄ Critical" + when 2 then "🟠 High" + when 3 then "🟑 Medium" + when 4 then "🟒 Low" + when 5 then "βšͺ Very Low" + end + puts " #{priority_label}: #{count}" end -# Show project task counts -puts "\nTasks per Project:" -Project.includes(:tasks).each do |project| - incomplete = project.tasks.where.not(status: 'done').count - puts " #{project.name}: #{project.tasks.count} total (#{incomplete} incomplete)" +puts "\nπŸ“ Projects by Activity Status:" +puts "\n🟒 RECENTLY ACTIVE (last 2 months):" +%w[am supap-front supap-back creaciones-del-mago personal-site ai-assistant-development-kit].each do |name| + p = Project.find_by(name: name) + puts " β€’ #{p.name}: #{p.tasks.count} tasks" if p end -puts "=" * 50 + +puts "\n🟑 PAUSED (3-5 months):" +%w[maicemita-site avent-properties train-uy pomodoro linear-clone trees-software-landing].each do |name| + p = Project.find_by(name: name) + puts " β€’ #{p.name}: #{p.tasks.count} tasks" if p +end + +puts "\nπŸ”΅ EARLY STAGE / MAINTENANCE:" +%w[aldea-infinita ML-props-scraper].each do |name| + p = Project.find_by(name: name) + puts " β€’ #{p.name}: #{p.tasks.count} tasks" if p +end + +puts "\n🟒 THIS PROJECT:" +p = Project.find_by(name: "task-tracker") +puts " β€’ #{p.name}: #{p.tasks.count} tasks (#{p.tasks.where(status: 'done').count} done)" if p + +puts "=" * 70 +puts "\nπŸ’‘ TIP: Run 'rails db:seed:replant' to reset and reload this data" +puts "=" * 70 diff --git a/db/seeds_example.rb b/db/seeds_example.rb new file mode 100644 index 0000000..5caf729 --- /dev/null +++ b/db/seeds_example.rb @@ -0,0 +1,201 @@ +# Clear existing data +puts "Clearing existing data..." +Task.destroy_all +Project.destroy_all + +# Project data +projects_data = [ + { + name: "Website Redesign", + description: "Redesign the company website with modern UI/UX and improved accessibility" + }, + { + name: "Mobile App Development", + description: "Build a cross-platform mobile app for iOS and Android using React Native" + }, + { + name: "Marketing Campaign Q1", + description: "Launch comprehensive marketing campaign for Q1 2025" + }, + { + name: "API Modernization", + description: "Migrate legacy REST API to GraphQL and improve performance" + }, + { + name: "Customer Portal", + description: "Build self-service customer portal with account management features" + }, + { + name: "Data Analytics Dashboard", + description: "Create real-time analytics dashboard for business metrics" + }, + { + name: "Infrastructure Upgrade", + description: "Upgrade cloud infrastructure and implement auto-scaling" + }, + { + name: "Security Audit", + description: "Conduct comprehensive security audit and implement fixes" + }, + { + name: "Documentation Overhaul", + description: "Rewrite technical documentation and create video tutorials" + }, + { + name: "Employee Onboarding System", + description: "Build automated onboarding system for new hires" + } +] + +# Task templates with variety of titles and descriptions +task_templates = [ + # Design tasks + { title: "Create wireframes", description: "Design low-fidelity wireframes for user flow", category: :design }, + { title: "Design mockups", description: "Create high-fidelity mockups in Figma", category: :design }, + { title: "Build design system", description: "Establish design system with components and tokens", category: :design }, + { title: "Conduct user research", description: "Interview users and gather feedback", category: :design }, + { title: "Create prototypes", description: "Build interactive prototypes for testing", category: :design }, + + # Development tasks + { title: "Setup project structure", description: "Initialize project with required dependencies", category: :development }, + { title: "Implement authentication", description: "Add user authentication with OAuth2", category: :development }, + { title: "Build REST API endpoints", description: "Create RESTful API endpoints for core features", category: :development }, + { title: "Add database migrations", description: "Create and run database schema migrations", category: :development }, + { title: "Implement search functionality", description: "Add full-text search with Elasticsearch", category: :development }, + { title: "Write unit tests", description: "Add comprehensive unit test coverage", category: :development }, + { title: "Setup CI/CD pipeline", description: "Configure automated testing and deployment", category: :development }, + { title: "Optimize database queries", description: "Refactor slow queries and add indexes", category: :development }, + { title: "Add caching layer", description: "Implement Redis caching for performance", category: :development }, + { title: "Build admin dashboard", description: "Create admin interface for management", category: :development }, + + # Testing tasks + { title: "Write integration tests", description: "Add end-to-end integration test suite", category: :testing }, + { title: "Perform load testing", description: "Test application under high load conditions", category: :testing }, + { title: "Conduct security testing", description: "Run penetration tests and security scans", category: :testing }, + { title: "UAT with stakeholders", description: "User acceptance testing with business team", category: :testing }, + + # DevOps tasks + { title: "Setup monitoring", description: "Configure APM and error tracking", category: :devops }, + { title: "Implement logging", description: "Add structured logging with ELK stack", category: :devops }, + { title: "Configure backups", description: "Setup automated database backups", category: :devops }, + { title: "Setup staging environment", description: "Create staging environment matching production", category: :devops }, + { title: "Implement auto-scaling", description: "Configure horizontal pod autoscaling", category: :devops }, + + # Documentation tasks + { title: "Write API documentation", description: "Document all API endpoints with examples", category: :documentation }, + { title: "Create user guides", description: "Write comprehensive user documentation", category: :documentation }, + { title: "Record demo videos", description: "Create video tutorials for key features", category: :documentation }, + { title: "Update README", description: "Update project README with latest information", category: :documentation }, + + # Management tasks + { title: "Sprint planning", description: "Plan upcoming sprint with team", category: :management }, + { title: "Code review", description: "Review pull requests from team members", category: :management }, + { title: "Stakeholder meeting", description: "Present progress to stakeholders", category: :management }, + { title: "Team retrospective", description: "Conduct sprint retrospective meeting", category: :management }, + + # Bug fixes + { title: "Fix login bug", description: "Resolve issue with login timeout", category: :bugfix }, + { title: "Fix payment processing", description: "Debug payment gateway integration issue", category: :bugfix }, + { title: "Fix mobile responsiveness", description: "Resolve layout issues on mobile devices", category: :bugfix }, + { title: "Fix data validation", description: "Add missing validation rules", category: :bugfix }, + { title: "Fix email notifications", description: "Debug email delivery failures", category: :bugfix } +] + +# Status distribution (realistic project distribution) +# 50% todo, 30% in_progress, 20% done +def weighted_status + rand_num = rand + if rand_num < 0.5 + "todo" + elsif rand_num < 0.8 + "in_progress" + else + "done" + end +end + +# Create projects +puts "Creating projects..." +projects = projects_data.map do |project_data| + Project.create!(project_data) +end + +# Create 100 tasks distributed across projects +puts "Creating tasks..." +task_count = 0 +target_tasks = 100 + +projects.each_with_index do |project, project_index| + # Distribute tasks unevenly (some projects have more tasks) + tasks_for_project = case project_index + when 0..2 then 15 # First 3 projects get 15 tasks each + when 3..5 then 10 # Next 3 projects get 10 tasks each + when 6..8 then 7 # Next 3 projects get 7 tasks each + else 4 # Last project gets 4 tasks + end + + tasks_for_project.times do |i| + break if task_count >= target_tasks + + # Select a random task template + template = task_templates.sample + + # Determine status based on weights + status = weighted_status + + # Priority (1-5, with bias toward 2-3) + priority = [ 1, 2, 2, 3, 3, 3, 4, 4, 5 ].sample + + # Due date logic + due_date = if rand < 0.1 # 10% have no due date + nil + elsif rand < 0.2 # 20% are overdue + rand(1..14).days.ago + elsif rand < 0.5 # 30% are due soon (next 7 days) + rand(1..7).days.from_now + else # 40% are due later + rand(8..30).days.from_now + end + + # Adjust status for completed tasks (they shouldn't be overdue) + if status == "done" && due_date && due_date < Date.today + due_date = rand(1..30).days.ago + end + + Task.create!( + project: project, + title: "#{template[:title]} - Phase #{i + 1}", + description: template[:description], + status: status, + priority: priority, + due_date: due_date + ) + + task_count += 1 + end +end + +# Summary statistics +puts "\n" + "=" * 50 +puts "Seed data created successfully!" +puts "=" * 50 +puts "Projects: #{Project.count}" +puts "Tasks: #{Task.count}" +puts "\nTask Breakdown:" +puts " Todo: #{Task.where(status: 'todo').count}" +puts " In Progress: #{Task.where(status: 'in_progress').count}" +puts " Done: #{Task.where(status: 'done').count}" +puts "\nOverdue tasks: #{Task.overdue.count}" +puts "\nPriority Distribution:" +(1..5).each do |priority| + count = Task.where(priority: priority).count + puts " Priority #{priority}: #{count}" +end + +# Show project task counts +puts "\nTasks per Project:" +Project.includes(:tasks).each do |project| + incomplete = project.tasks.where.not(status: 'done').count + puts " #{project.name}: #{project.tasks.count} total (#{incomplete} incomplete)" +end +puts "=" * 50