Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove RandomDataSeeder

Christophe Bliardd0005bff700d
diff --git a/app/seeders/random_data/forum_seeder.rb b/app/seeders/random_data/forum_seeder.rb
deleted file mode 100644
index 13a260c43cf..00000000000
--- a/app/seeders/random_data/forum_seeder.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-module RandomData
- class ForumSeeder
- def self.seed!(project)
- user = User.admin.first
-
- puts ''
- print_status ' ↳ Creating forum with posts'
-
- forum = Forum.create! project: project,
- name: I18n.t("seeders.#{OpenProject::Configuration['edition']}.demo_data.board.name"),
- description: I18n.t("seeders.#{OpenProject::Configuration['edition']}.demo_data.board.description")
-
- rand(30).times do
- print_status '.'
- message = Message.create forum: forum,
- author: user,
- subject: Faker::Lorem.words(5).join(' '),
- content: Faker::Lorem.paragraph(5, true, 3)
-
- rand(5).times do
- print_status '.'
- Message.create forum:,
- author: user,
- subject: message.subject,
- content: Faker::Lorem.paragraph(5, true, 3),
- parent: message
- end
- end
- end
- end
-end
diff --git a/app/seeders/random_data/news_seeder.rb b/app/seeders/random_data/news_seeder.rb
deleted file mode 100644
index 1e3a9656874..00000000000
--- a/app/seeders/random_data/news_seeder.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-module RandomData
- class NewsSeeder
- def self.seed!(project)
- user = User.admin.first
-
- puts ''
- print_status ' ↳ Creating news'
-
- rand(30).times do
- print_status '.'
- news = News.create project: project,
- author: user,
- title: Faker::Lorem.characters(60),
- summary: Faker::Lorem.paragraph(1, true, 3),
- description: Faker::Lorem.paragraph(5, true, 3)
-
- ## create some journal entries
- rand(5).times do
- news.reload
-
- news.title = Faker::Lorem.words(5).join(' ').slice(0, 60) if rand(99).even?
- news.summary = Faker::Lorem.paragraph(1, true, 3) if rand(99).even?
- news.description = Faker::Lorem.paragraph(5, true, 3) if rand(99).even?
-
- news.save!
- end
- end
- end
- end
-end
diff --git a/app/seeders/random_data/wiki_seeder.rb b/app/seeders/random_data/wiki_seeder.rb
deleted file mode 100644
index 673f50d4eb2..00000000000
--- a/app/seeders/random_data/wiki_seeder.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-module RandomData
- class WikiSeeder
- def self.seed!(project)
- user = User.admin.first
-
- puts ''
- print_status ' ↳ Creating wikis'
-
- rand(5).times do
- print_status '.'
- wiki_page = WikiPage.create(
- wiki: project.wiki,
- title: Faker::Lorem.words(5).join(' ')
- )
-
- ## create some wiki contents
- rand(5).times do
- print_status '.'
- wiki_content = WikiContent.create(
- page: wiki_page,
- author: user,
- text: Faker::Lorem.paragraph(5, true, 3)
- )
-
- ## create some journal entries
- rand(5).times do
- wiki_content.reload
- wiki_content.text = Faker::Lorem.paragraph(5, true, 3) if rand(99).even?
- wiki_content.save!
- end
- end
- end
- end
- end
-end
diff --git a/app/seeders/random_data/work_package_seeder.rb b/app/seeders/random_data/work_package_seeder.rb
deleted file mode 100644
index dbfcf035793..00000000000
--- a/app/seeders/random_data/work_package_seeder.rb
+++ /dev/null
@@ -1,188 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-module RandomData
- class WorkPackageSeeder
- attr_accessor :project, :user, :statuses, :repository, :types
-
- def initialize(project)
- self.project = project
- self.user = User.admin.first
- self.statuses = Status.all
- self.repository = Repository.first
- self.types = project.types.all.reject(&:is_milestone?)
- end
-
- def seed!(random: true)
- puts ''
- print_status ' ↳ Creating work_packages'
-
- seed_random_work_packages
- end
-
- private
-
- def seed_random_work_packages
- rand(50).times do
- print_status '.'
- work_package = WorkPackage.create!(
- project:,
- author: user,
- subject: Faker::Lorem.words(8).join(' '),
- status: statuses.sample,
- type: types.sample,
- start_date: s = Date.today - rand(-24..25).days,
- due_date: s + rand(1..120).days
- )
- work_package.priority = IssuePriority.all.sample
- work_package.description = Faker::Lorem.paragraph(5, true, 3)
- work_package.save!
- end
-
- work_package = WorkPackage.first
-
- if repository
- add_changeset(work_package)
- end
-
- add_time_entries(work_package)
- add_attachments(work_package)
- add_custom_values(work_package)
- make_changes(work_package)
- end
-
- def add_changeset(work_package)
- 2.times do |changeset_count|
- print_status '.'
- changeset = Changeset.create(
- repository:,
- user:,
- revision: (work_package.id * 10) + changeset_count,
- scmid: (work_package.id * 10) + changeset_count,
- work_packages: [work_package],
- committer: Faker::Name.name,
- committed_on: Date.today,
- comments: Faker::Lorem.words(8).join(' ')
- )
-
- 5.times do
- print_status '.'
- change = Change.create(
- action: Faker::Lorem.characters(1),
- path: Faker::Internet.url
- )
-
- changeset.file_changes << change
- end
-
- repository.changesets << changeset
-
- changeset.save!
-
- rand(5).times do
- print_status '.'
- changeset.reload
-
- changeset.committer = Faker::Name.name if rand(99).even?
- changeset.committed_on = Date.today + rand(999) if rand(99).even?
- changeset.comments = Faker::Lorem.words(8).join(' ') if rand(99).even?
-
- changeset.save!
- end
- end
- end
-
- def add_time_entries(work_package)
- 5.times do |time_entry_count|
- time_entry = TimeEntry.create(
- project:,
- user:,
- work_package:,
- spent_on: Date.today + time_entry_count,
- activity: time_entry_activities.sample,
- hours: time_entry_count
- )
- work_package.time_entries << time_entry
- end
- end
-
- def add_attachments(work_package)
- 3.times do |_attachment_count|
- file = OpenProject::Files.create_uploaded_file(name: Faker::Lorem.words(8).join(' '))
- attachment = Attachment.new(
- container: work_package,
- author: user,
- file:
- )
- attachment.save!
-
- work_package.attachments << attachment
- end
- end
-
- def add_custom_values(work_package)
- project.work_package_custom_fields.each do |custom_field|
- work_package.type.custom_fields << custom_field if !work_package.type.custom_fields.include?(custom_field)
- work_package.custom_values << CustomValue.new(custom_field:,
- value: Faker::Lorem.words(8).join(' '))
- end
-
- work_package.type.save!
- work_package.save!
- end
-
- def make_changes(work_package)
- 20.times do
- print_status '.'
- work_package.reload
-
- work_package.status = statuses.sample if rand(99).even?
- work_package.subject = Faker::Lorem.words(8).join(' ') if rand(99).even?
- work_package.description = Faker::Lorem.paragraph(5, true, 3) if rand(99).even?
- work_package.type = types.sample if rand(99).even?
-
- work_package.time_entries.each do |t|
- t.spent_on = Date.today + rand(100) if rand(99).even?
- t.activity = time_entry_activities.sample if rand(99).even?
- t.hours = rand(10) if rand(99).even?
- end
-
- work_package.reload
-
- attachments = work_package.attachments.select { |_a| rand(999) < 10 }
- work_package.attachments = work_package.attachments - attachments
-
- work_package.reload
-
- work_package.custom_values.each do |cv|
- cv.value = Faker::Code.isbn if rand(99).even?
- end
-
- work_package.save!
- end
- end
- end
-end
diff --git a/app/seeders/random_data_seeder.rb b/app/seeders/random_data_seeder.rb
deleted file mode 100644
index 523a8c34e3c..00000000000
--- a/app/seeders/random_data_seeder.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-class RandomDataSeeder
- def self.seed!
- puts ' ########################################################'
- puts ' # WARNING: THIS DELETES ANY DEMO DATA THAT WAS SEEDED #'
- puts ' ########################################################'
-
- project = DemoData::ProjectSeeder.seed!
-
- DemoData::CustomFieldSeeder.seed!(project)
- RandomData::ForumSeeder.seed!(project)
- RandomData::NewsSeeder.seed!(project)
- RandomData::WikiSeeder.seed!(project)
- RandomData::WorkPackageSeeder.new(project).seed!
-
- puts "\n\n"
- puts ' ################################'
- puts ' # Random seeding....done #'
- puts ' ################################'
- puts " # %02d %-23s #" % [WorkPackage.where(project_id: project.id).count, 'issues created.']
- puts " # %02d %-23s #" % [Message.joins(:board).where(boards: { project_id: project.id }).count, 'messages created.']
- puts " # %02d %-23s #" % [News.where(project_id: project.id).count, 'news created.']
- puts " # %02d %-23s #" % [WikiContent.joins(page: [:wiki]).where('wikis.project_id = ?', project.id).count,
- 'wiki contents created.']
- puts " # %02d %-23s #" % [TimeEntry.where(project_id: project.id).count, 'time entries created.']
- puts " # %02d %-23s #" % [Changeset.joins(:repository).where(repositories: { project_id: project.id }).count,
- 'changesets created.']
- puts " ################################\n\n"
- end
-end
diff --git a/lib/tasks/random_data.rake b/lib/tasks/random_data.rake
deleted file mode 100644
index 27f6f553bf0..00000000000
--- a/lib/tasks/random_data.rake
+++ /dev/null
@@ -1,46 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2022 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-namespace :random_data do
- desc 'seeds the data base wth random data'
- task seed: :environment do
- puts '*** Seeding basic data'
- BasicDataSeeder.seed!
-
- puts '*** Seeding admin user'
- AdminUserSeeder.new.seed!
-
- puts '*** Seeding demo data'
- RandomDataSeeder.seed!
-
- ::Rails::Engine.subclasses.map(&:instance).each do |engine|
- puts "*** Loading #{engine.engine_name} seed data"
- engine.load_seed
- end
- end
-end