API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. User.delete_all
  2. User.reset_pk_sequence
  3. Activity.delete_all
  4. Activity.reset_pk_sequence
  5. JoinedUserActivity.delete_all
  6. JoinedUserActivity.reset_pk_sequence
  7. Task.delete_all
  8. Task.reset_pk_sequence
  9. Record.delete_all
  10. Record.reset_pk_sequence
  11. 10.times do |i|
  12. name = Faker::Name.first_name.downcase
  13. user = User.create! username: "#{name}", email: "#{name}@email.com", password: "azerty"
  14. puts "Created USER ##{i} - #{user.username}"
  15. 2.times do
  16. activity = Activity.create!(
  17. name: Faker::Science.element,
  18. client: Faker::Company.name,
  19. description: Faker::Company.catch_phrase,
  20. author_id: user.id
  21. )
  22. puts "Created ACTIVITY \"#{activity.name}\" for #{activity.client}"
  23. joined_user_activity = JoinedUserActivity.create!(
  24. user_id: user.id,
  25. activity_id: activity.id
  26. )
  27. puts "Created ASSOCIATION ##{joined_user_activity.id}"
  28. end
  29. end
  30. 30.times do |i|
  31. task = Task.create(
  32. name: Faker::Fantasy::Tolkien.character,
  33. description: Faker::Fantasy::Tolkien.poem,
  34. user_id: User.all.sample.id,
  35. activity_id: Activity.all.sample.id
  36. )
  37. puts "Created TASK ##{i} - #{task.name}"
  38. end
  39. 20.times do |i|
  40. record = Record.create(
  41. duration: rand(60..480),
  42. user_id: User.all.sample.id,
  43. task_id: Task.all.sample.id
  44. )
  45. puts "Created RECORD ##{i}"
  46. end