Merge branch 'development_updates' into 'develop'

Development updates

See merge request gab/social/gab-social!61
This commit is contained in:
Free Speech Forever 2021-02-15 01:11:39 +00:00
commit 2b563148a8
7 changed files with 68 additions and 41 deletions

View File

@ -1,3 +1,7 @@
VAGRANT=true
LOCAL_DOMAIN=gabsocial.local
DB_HOST=/var/run/postgresql/
DB_MASTER_URL=postgres:///gabsocial_development
DB_SLAVE1_URL=postgres:///gabsocial_development
DB_SLAVE2_URL=postgres:///gabsocial_development
ELASTIC_APM_ENABLED=false

View File

@ -111,7 +111,6 @@ end
group :test do
gem 'capybara', '~> 3.22'
gem 'climate_control', '~> 0.2'
gem 'faker', '~> 1.9'
gem 'microformats', '~> 4.1'
gem 'rails-controller-testing', '~> 1.0'
gem 'rspec-sidekiq', '~> 3.0'
@ -126,6 +125,7 @@ group :development do
gem 'better_errors', '~> 2.5'
gem 'binding_of_caller', '~> 0.7'
gem 'bullet', '~> 6.0'
gem 'faker', '~> 2.15'
gem 'listen'
gem 'letter_opener', '~> 1.7'
gem 'letter_opener_web', '~> 1.3'
@ -141,6 +141,7 @@ group :development do
gem 'capistrano-yarn', '~> 2.0'
gem 'derailed_benchmarks'
gem 'rack-mini-profiler'
gem 'stackprof'
end

View File

@ -227,8 +227,8 @@ GEM
tzinfo
excon (0.78.1)
fabrication (2.21.1)
faker (1.9.6)
i18n (>= 0.7)
faker (2.15.1)
i18n (>= 1.6, < 2)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
@ -296,7 +296,7 @@ GEM
httplog (1.4.3)
rack (>= 1.0)
rainbow (>= 2.0.0)
i18n (1.8.7)
i18n (1.8.8)
concurrent-ruby (~> 1.0)
i18n-tasks (0.9.33)
activesupport (>= 4.0.2)
@ -455,6 +455,8 @@ GEM
rack (>= 1.0, < 3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-mini-profiler (2.3.1)
rack (>= 1.2.0)
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
@ -701,7 +703,7 @@ DEPENDENCIES
dotenv-rails (~> 2.7)
elastic-apm (~> 3.13)
fabrication (~> 2.20)
faker (~> 1.9)
faker (~> 2.15)
fast_blank (~> 1.0)
fastimage
fog-core (<= 2.1.0)
@ -753,6 +755,7 @@ DEPENDENCIES
pundit (~> 2.0)
rack-attack (~> 6.0)
rack-cors (~> 1.0)
rack-mini-profiler
rails (= 6.0.3.4)
rails-controller-testing (~> 1.0)
rails-i18n (~> 6.0.0)

4
Vagrantfile vendored
View File

@ -48,8 +48,8 @@ sudo apt-get install \
libpam0g-dev \
-y
# Start Redis Server
sudo service redis-server start
# Start Redis Server on boot (and right now)
sudo systemctl enable --now redis-server
# Install rvm
read RUBY_VERSION < .ruby-version

View File

@ -4,26 +4,20 @@ default: &default
timeout: 5000
encoding: unicode
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
development:
master:
adapter: postgresql
<<: *default
url: <%= ENV['DB_MASTER_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
slave1:
adapter: postgresql
<<: *default
url: <%= ENV['DB_SLAVE1_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
replica: true
slave2:
adapter: postgresql
<<: *default
url: <%= ENV['DB_SLAVE2_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
replica: true
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
@ -46,27 +40,13 @@ test:
# prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>
production:
master:
adapter: postgresql
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
<<: *default
url: <%= ENV['DB_MASTER_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
slave1:
adapter: postgresql
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
<<: *default
url: <%= ENV['DB_SLAVE1_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
replica: true
slave2:
adapter: postgresql
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
<<: *default
url: <%= ENV['DB_SLAVE1_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
replica: true

View File

@ -9,3 +9,5 @@ secret_token: <%= ENV['ELASTIC_APM_SECRET_TOKEN'] || '' %>
# Set custom APM Server URL (default: http://localhost:8200)
server_url: <%= ENV['ELASTIC_APM_URL'] || 'http://localhost:8200'%>
enabled: <%= ENV['ELASTIC_APM_ENABLED'] || 'true' %>

37
lib/tasks/dummy_data.rake Normal file
View File

@ -0,0 +1,37 @@
# frozen_string_literal: true
desc 'Import dummy data into the database, to create a more realistic development experience'
task dummy_data: :environment do
raise 'Only run this in development' unless Rails.env.development?
domain = ENV['LOCAL_DOMAIN'] || Rails.configuration.x.local_domain
admin = Account.find_by!(username: 'admin')
accounts = 1.upto(1_000).map do |num|
username = "#{Faker::Internet.username(separators: %w[_])}#{num}"
password = Faker::Internet.password
Account.create!(username: username).tap do |account|
account.create_user!({
email: "#{username}@#{domain}",
password: password,
password_confirmation: password,
agreement: true,
approved: true
})
end
end
accounts.each do |acct|
FollowService.new.call(admin, acct)
end
statuses = (accounts + [admin]).map do |account|
PostStatusService.new.call(account, text: Faker::Lorem.paragraph(sentence_count: 20))
end
accounts.sample(200).zip(statuses.sample(200)).each do |account, status|
ReblogService.new.call(account, status)
end
end