From e54dc523c6770f01c49f7c49f98aaff0c2f9df04 Mon Sep 17 00:00:00 2001 From: Vitaly Slobodin Date: Sun, 28 Apr 2024 17:00:53 +0200 Subject: [PATCH] Add more dev seeds --- Gemfile | 2 ++ Gemfile.lock | 32 +++++++++++++++++++ db/seeds.rb | 46 ---------------------------- db/seeds/development/events.seeds.rb | 36 ++++++++++++++++++++++ db/seeds/development/places.seeds.rb | 20 ++++++++++++ db/seeds/development/users.seeds.rb | 8 +++++ 6 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 db/seeds/development/events.seeds.rb create mode 100644 db/seeds/development/places.seeds.rb create mode 100644 db/seeds/development/users.seeds.rb diff --git a/Gemfile b/Gemfile index 11cf566d2..f8dc83492 100644 --- a/Gemfile +++ b/Gemfile @@ -59,6 +59,8 @@ end group :development do gem "active_record_query_trace", require: false gem "listen" + gem "seedbank", "~> 0.5" + gem "solargraph", require: false end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 1112f9ee9..b39089c53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,8 +78,10 @@ GEM ast (2.4.2) autoprefixer-rails (9.6.1.1) execjs + backport (1.2.0) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.3.0) bigdecimal (3.1.7) bootsnap (1.18.3) msgpack (~> 1.2) @@ -173,6 +175,7 @@ GEM dry-initializer (~> 3.0) dry-schema (>= 1.12, < 2) zeitwerk (~> 2.6) + e2mmap (0.1.0) erubi (1.12.0) execjs (2.7.0) factory_bot (6.4.5) @@ -211,6 +214,7 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) + jaro_winkler (1.5.6) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -218,6 +222,10 @@ GEM json (2.7.2) jwt (2.8.1) base64 + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) language_server-protocol (3.17.0.3) launchy (2.4.3) addressable (~> 2.3) @@ -371,6 +379,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rbs (2.8.4) recipient_interceptor (0.2.0) mail redcarpet (3.5.1) @@ -378,6 +387,8 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) + reverse_markdown (2.1.1) + nokogiri rexml (3.2.6) rspec-core (3.13.0) rspec-support (~> 3.13.0) @@ -444,6 +455,8 @@ GEM sprockets (> 3.0) sprockets-rails tilt + seedbank (0.5.0) + rake (>= 10.0) shoulda-callback-matchers (1.1.4) activesupport (>= 3) shoulda-matchers (6.2.0) @@ -464,6 +477,22 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) + solargraph (0.50.0) + backport (~> 1.2) + benchmark + bundler (~> 2.0) + diff-lcs (~> 1.4) + e2mmap + jaro_winkler (~> 1.5) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + parser (~> 3.0) + rbs (~> 2.0) + reverse_markdown (~> 2.0) + rubocop (~> 1.38) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9, >= 0.9.24) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -501,6 +530,7 @@ GEM will_paginate (3.2.1) xpath (3.2.0) nokogiri (~> 1.8) + yard (0.9.36) zeitwerk (2.6.13) PLATFORMS @@ -568,10 +598,12 @@ DEPENDENCIES rubocop-rails-omakase russian sass-rails (~> 6.0) + seedbank (~> 0.5) shoulda-callback-matchers shoulda-matchers simplecov slim-rails + solargraph sprockets (>= 3.0.0) stackprof timecop diff --git a/db/seeds.rb b/db/seeds.rb index 46445b8c0..e36e270f8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,51 +1,5 @@ -Place.create!([ - { title: 'Рабочее пространство "MESTO"', address: 'улица Максима Горького, 151', latitude: 47.226894, longitude: 39.714285, created_at: '2016-08-25 12:11:41.806837', updated_at: '2016-08-25 12:11:41.806837' }, - { title: 'Креативное пространство CreativeSpace.pro', address: 'улица Суворова, 52А', latitude: 47.225193, longitude: 39.728838, created_at: '2016-08-26 09:04:34.626668', updated_at: '2016-08-26 09:04:34.626668' }, - { title: 'Южный IT-парк', address: 'улица Суворова, 91', latitude: 47.226796, longitude: 39.732746, created_at: '2016-08-26 09:05:08.291215', updated_at: '2016-08-26 09:05:08.291215' }, - { title: 'Учебный Центр «Эксперт»', address: 'улица Станиславского, 167/25', latitude: 47.222415, longitude: 39.735054, created_at: '2016-08-26 09:05:57.700912', updated_at: '2016-08-26 09:05:57.700912' }, - { title: 'Отель «Атташе»', address: 'проспект Соколова, 19', latitude: 47.223883, longitude: 39.72069, created_at: '2016-08-26 09:06:23.073808', updated_at: '2016-08-26 09:06:23.073808' }, - { title: 'Конгресс-отель «Амакс»', address: 'проспект Михаила Нагибина, 19', latitude: 47.248779, longitude: 39.711851, created_at: '2016-08-26 09:07:06.816933', updated_at: '2016-08-26 09:07:06.816933' }, - { title: 'ИФЖиМКК ЮФУ', address: 'Университетский переулок, 93', latitude: 47.226766, longitude: 39.726808, created_at: '2016-08-26 09:07:56.474912', updated_at: '2016-08-26 09:07:56.474912' }, - { title: 'База отдыха «Казачок»', address: 'Очаковская коса', latitude: 47.031146, longitude: 39.099065, created_at: '2016-08-26 09:09:26.087182', updated_at: '2016-08-26 09:09:26.087182' }, - { title: 'Конгресс-отель «Дон-Плаза»', address: 'Большая Садовая улица, 115', latitude: 47.226117, longitude: 39.734327, created_at: '2016-08-26 09:09:40.030728', updated_at: '2016-08-26 09:09:40.030728' }, - { title: 'Офис «Game Insight»', address: 'Таганрог, Петровская улица, 26', latitude: 47.207964, longitude: 38.941527, created_at: '2016-08-26 09:10:05.032555', updated_at: '2016-08-26 09:10:05.032555' }, - { title: 'ДГТУ, 7 корпус', address: 'площадь Гагарина, 1', latitude: 47.237412, longitude: 39.712632, created_at: '2016-08-26 09:12:13.254869', updated_at: '2016-08-26 09:12:13.254869' }, - { title: 'Бизнс-центр «Оптима Ленд»', address: 'Таганрог, улица Москатова, 31/2', latitude: 47.257317, longitude: 38.911308, created_at: '2016-08-26 09:13:02.004318', updated_at: '2016-08-26 09:13:02.004318' }, - { title: 'Свободное пространство «Циферблат»', address: 'проспект Соколова, 46', latitude: 47.225872, longitude: 39.720466, created_at: '2016-08-26 09:13:41.476870', updated_at: '2016-08-26 09:13:41.476870' }, - { title: 'DobroCowork University', address: 'улица 16-я Линия, 7В', latitude: 47.231355, longitude: 39.759354, created_at: '2016-08-26 09:14:22.045622', updated_at: '2016-08-26 09:14:22.045622' }, - { title: 'AZIMUT Hotel Sochi 3*', address: 'Сочи, Континентальный проспект, 6', latitude: 43.402584, longitude: 39.973099, created_at: '2016-08-26 09:14:48.345412', updated_at: '2016-08-26 09:14:48.345412' }, - { title: 'ДГТУ, Академия строительства и архитектуры', address: 'Социалистическая улица, 162/32', latitude: 47.223736, longitude: 39.732278, created_at: '2016-08-26 09:16:23.618108', updated_at: '2016-08-26 09:16:23.618108' } - ]) - # Groups Group.create!([ { name: "Разработчик IT61", kind: 1 }, { name: "Команда IT61", kind: 2 } ]) - -User.create!(email: 'user@it61.info.local', first_name: 'Река', last_name: 'Дон', role: User.roles[:member]) - -Event.create!([ - { - description: 'Описание тестового события в прошлом', - place: Place.first, - title: 'Прошедшее событие', - organizer: User.first, - started_at: 1.week.ago, - published: true, - published_at: 2.weeks.ago, - # TODO(vitallium): Move to fixtures? - cover: Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "files", "event_title_image.jpg")) - }, - { - description: 'Описание тестового события в будущем', - place: Place.last, - title: 'Будущее событие', - organizer: User.first, - started_at: 1.week.from_now, - published: true, - published_at: 1.day.ago, - # TODO(vitallium): Move to fixtures? - cover: Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "files", "event_title_image.jpg")) - } - ]) diff --git a/db/seeds/development/events.seeds.rb b/db/seeds/development/events.seeds.rb new file mode 100644 index 000000000..00d7791b5 --- /dev/null +++ b/db/seeds/development/events.seeds.rb @@ -0,0 +1,36 @@ +after "development:places" do + (1..5).each do + # Unpublished events + Event.create!( + title: Faker::Esport.event, + description: Faker::Markdown.sandwich(sentences: 6, repeat: 3), + organizer: User.order("RANDOM()").first, + started_at: Faker::Time.forward(days: 30), + published: false, + place: Place.order("RANDOM()").first + ) + + # Upcoming events + Event.create!( + title: Faker::Esport.event, + description: Faker::Markdown.sandwich(sentences: 6, repeat: 3), + organizer: User.order("RANDOM()").first, + started_at: Faker::Time.forward(days: 30), + published: true, + published_at: Date.current, + place: Place.order("RANDOM()").first + + ) + + # Past events + Event.create!( + title: Faker::Esport.event, + description: Faker::Markdown.sandwich(sentences: 6, repeat: 3), + organizer: User.order("RANDOM()").first, + started_at: Faker::Time.backward(days: 30), + published: true, + published_at: Faker::Time.backward(days: 10), + place: Place.order("RANDOM()").first + ) + end +end diff --git a/db/seeds/development/places.seeds.rb b/db/seeds/development/places.seeds.rb new file mode 100644 index 000000000..cd6c2f358 --- /dev/null +++ b/db/seeds/development/places.seeds.rb @@ -0,0 +1,20 @@ +after "development:users" do + Place.create!([ + { title: 'Рабочее пространство "MESTO"', address: 'улица Максима Горького, 151', latitude: 47.226894, longitude: 39.714285, created_at: '2016-08-25 12:11:41.806837', updated_at: '2016-08-25 12:11:41.806837' }, + { title: 'Креативное пространство CreativeSpace.pro', address: 'улица Суворова, 52А', latitude: 47.225193, longitude: 39.728838, created_at: '2016-08-26 09:04:34.626668', updated_at: '2016-08-26 09:04:34.626668' }, + { title: 'Южный IT-парк', address: 'улица Суворова, 91', latitude: 47.226796, longitude: 39.732746, created_at: '2016-08-26 09:05:08.291215', updated_at: '2016-08-26 09:05:08.291215' }, + { title: 'Учебный Центр «Эксперт»', address: 'улица Станиславского, 167/25', latitude: 47.222415, longitude: 39.735054, created_at: '2016-08-26 09:05:57.700912', updated_at: '2016-08-26 09:05:57.700912' }, + { title: 'Отель «Атташе»', address: 'проспект Соколова, 19', latitude: 47.223883, longitude: 39.72069, created_at: '2016-08-26 09:06:23.073808', updated_at: '2016-08-26 09:06:23.073808' }, + { title: 'Конгресс-отель «Амакс»', address: 'проспект Михаила Нагибина, 19', latitude: 47.248779, longitude: 39.711851, created_at: '2016-08-26 09:07:06.816933', updated_at: '2016-08-26 09:07:06.816933' }, + { title: 'ИФЖиМКК ЮФУ', address: 'Университетский переулок, 93', latitude: 47.226766, longitude: 39.726808, created_at: '2016-08-26 09:07:56.474912', updated_at: '2016-08-26 09:07:56.474912' }, + { title: 'База отдыха «Казачок»', address: 'Очаковская коса', latitude: 47.031146, longitude: 39.099065, created_at: '2016-08-26 09:09:26.087182', updated_at: '2016-08-26 09:09:26.087182' }, + { title: 'Конгресс-отель «Дон-Плаза»', address: 'Большая Садовая улица, 115', latitude: 47.226117, longitude: 39.734327, created_at: '2016-08-26 09:09:40.030728', updated_at: '2016-08-26 09:09:40.030728' }, + { title: 'Офис «Game Insight»', address: 'Таганрог, Петровская улица, 26', latitude: 47.207964, longitude: 38.941527, created_at: '2016-08-26 09:10:05.032555', updated_at: '2016-08-26 09:10:05.032555' }, + { title: 'ДГТУ, 7 корпус', address: 'площадь Гагарина, 1', latitude: 47.237412, longitude: 39.712632, created_at: '2016-08-26 09:12:13.254869', updated_at: '2016-08-26 09:12:13.254869' }, + { title: 'Бизнс-центр «Оптима Ленд»', address: 'Таганрог, улица Москатова, 31/2', latitude: 47.257317, longitude: 38.911308, created_at: '2016-08-26 09:13:02.004318', updated_at: '2016-08-26 09:13:02.004318' }, + { title: 'Свободное пространство «Циферблат»', address: 'проспект Соколова, 46', latitude: 47.225872, longitude: 39.720466, created_at: '2016-08-26 09:13:41.476870', updated_at: '2016-08-26 09:13:41.476870' }, + { title: 'DobroCowork University', address: 'улица 16-я Линия, 7В', latitude: 47.231355, longitude: 39.759354, created_at: '2016-08-26 09:14:22.045622', updated_at: '2016-08-26 09:14:22.045622' }, + { title: 'AZIMUT Hotel Sochi 3*', address: 'Сочи, Континентальный проспект, 6', latitude: 43.402584, longitude: 39.973099, created_at: '2016-08-26 09:14:48.345412', updated_at: '2016-08-26 09:14:48.345412' }, + { title: 'ДГТУ, Академия строительства и архитектуры', address: 'Социалистическая улица, 162/32', latitude: 47.223736, longitude: 39.732278, created_at: '2016-08-26 09:16:23.618108', updated_at: '2016-08-26 09:16:23.618108' } + ]) +end diff --git a/db/seeds/development/users.seeds.rb b/db/seeds/development/users.seeds.rb new file mode 100644 index 000000000..f1394dc57 --- /dev/null +++ b/db/seeds/development/users.seeds.rb @@ -0,0 +1,8 @@ +(1..10).each do + User.create!( + first_name: Faker::Name.first_name, + last_name: Faker::Name.last_name, + bio: Faker::Lorem.paragraph, + email: Faker::Internet.email, + ) +end