DEV: Apply syntax_tree formatting to lib/*

This commit is contained in:
David Taylor
2023-01-09 12:10:19 +00:00
parent b0fda61a8e
commit 6417173082
507 changed files with 16550 additions and 12627 deletions

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true
require 'discourse_dev'
require 'rails'
require 'faker'
require "discourse_dev"
require "rails"
require "faker"
module DiscourseDev
class Record
@ -12,11 +12,12 @@ module DiscourseDev
attr_reader :model, :type
def initialize(model, count = DEFAULT_COUNT)
@@initialized ||= begin
Faker::Discourse.unique.clear
RateLimiter.disable
true
end
@@initialized ||=
begin
Faker::Discourse.unique.clear
RateLimiter.disable
true
end
@model = model
@type = model.to_s.downcase.to_sym
@ -40,11 +41,9 @@ module DiscourseDev
if current_count >= @count
puts "Already have #{current_count} #{type} records"
Rake.application.top_level_tasks.each do |task_name|
Rake::Task[task_name].reenable
end
Rake.application.top_level_tasks.each { |task_name| Rake::Task[task_name].reenable }
Rake::Task['dev:repopulate'].invoke
Rake::Task["dev:repopulate"].invoke
return
elsif current_count > 0
@count -= current_count
@ -74,7 +73,9 @@ module DiscourseDev
end
def self.random(model, use_existing_records: true)
model.joins(:_custom_fields).where("#{:type}_custom_fields.name = '#{AUTO_POPULATED}'") if !use_existing_records && model.new.respond_to?(:custom_fields)
if !use_existing_records && model.new.respond_to?(:custom_fields)
model.joins(:_custom_fields).where("#{:type}_custom_fields.name = '#{AUTO_POPULATED}'")
end
count = model.count
raise "#{:type} records are not yet populated" if count == 0