Fix Rubocop issues
This commit is contained in:
parent
a45008640f
commit
7f5d06b23c
27 changed files with 94 additions and 83 deletions
|
|
@ -13,24 +13,24 @@ namespace :db do
|
|||
end
|
||||
end
|
||||
|
||||
desc "Import a given file into the database"
|
||||
desc 'Import a given file into the database'
|
||||
task :import, [:path] => :environment do |_t, args|
|
||||
dump_path = args.path
|
||||
connection_config = ActiveRecord::Base.connection_config
|
||||
|
||||
case connection_config[:adapter]
|
||||
when "postgresql"
|
||||
when 'postgresql'
|
||||
system("PGPASSWORD=#{connection_config[:password]} pg_restore " \
|
||||
"--verbose --clean --no-acl --no-owner " \
|
||||
'--verbose --clean --no-acl --no-owner ' \
|
||||
"--username=#{connection_config[:username]} " \
|
||||
"-d #{connection_config[:database]} #{dump_path}")
|
||||
when "mysql", "mysql2"
|
||||
when 'mysql', 'mysql2'
|
||||
system("mysql -u #{connection_config[:username]} " \
|
||||
"-p#{connection_config[:password]} " \
|
||||
"#{connection_config[:database]} < #{dump_path}")
|
||||
else
|
||||
raise NotImplementedError, "An importer hasn't been implemented for: " \
|
||||
"#{connection_config[:adapter]}"
|
||||
raise NotImplementedError.new("An importer hasn't been implemented for: " \
|
||||
"#{connection_config[:adapter]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
namespace :registrations do
|
||||
desc "Create missing registrations for those how have a registration ticket."
|
||||
task :create_missing, [:conference] => :environment do |t, args|
|
||||
desc 'Create missing registrations for those how have a registration ticket.'
|
||||
task :create_missing, [:conference] => :environment do |_t, args|
|
||||
|
||||
fail 'Please supply a conference short name.' unless args.conference
|
||||
raise 'Please supply a conference short name.' unless args.conference
|
||||
|
||||
conf = Conference.find_by(short_title: args.conference)
|
||||
# Check if a user is found based on the supplied email address
|
||||
fail "Coud not find conference #{args.conference}" unless conf
|
||||
raise "Coud not find conference #{args.conference}" unless conf
|
||||
|
||||
purchases = conf.ticket_purchases.where(ticket: conf.registration_tickets, paid: true)
|
||||
unregistered = purchases.select { |tp| !conf.user_registered?(tp.user) }
|
||||
unregistered = purchases.reject { |tp| conf.user_registered?(tp.user) }
|
||||
puts "Found #{unregistered.count} unregistered users for #{purchases.count} ticket purchases."
|
||||
puts "There are currently #{conf.participants.count} registered users."
|
||||
|
||||
|
|
@ -19,17 +19,17 @@ namespace :registrations do
|
|||
puts "Creating registration for #{tp.user.email}"
|
||||
Registration.create(user: tp.user, conference: conf)
|
||||
end
|
||||
puts "Done."
|
||||
puts 'Done.'
|
||||
end
|
||||
|
||||
desc "Show User emails who have not paid, but did register"
|
||||
task :list_unpaid, [:conference] => :environment do |t, args|
|
||||
desc 'Show User emails who have not paid, but did register'
|
||||
task :list_unpaid, [:conference] => :environment do |_t, args|
|
||||
|
||||
fail 'Please supply a conference short name.' unless args.conference
|
||||
raise 'Please supply a conference short name.' unless args.conference
|
||||
|
||||
conf = Conference.find_by(short_title: args.conference)
|
||||
# Check if a user is found based on the supplied email address
|
||||
fail "Coud not find conference #{args.conference}" unless conf
|
||||
raise "Coud not find conference #{args.conference}" unless conf
|
||||
|
||||
registered = conf.participants
|
||||
unpaid = registered.select do |user|
|
||||
|
|
@ -41,6 +41,6 @@ namespace :registrations do
|
|||
unpaid.each do |user|
|
||||
puts "'#{user.name}'<#{user.email}>, "
|
||||
end
|
||||
puts ""
|
||||
puts ''
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue