Add info messages for release 1.0.0 tasks
So users know what's going on when they upgrade CONSUL.
This commit is contained in:
11
lib/application_logger.rb
Normal file
11
lib/application_logger.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class ApplicationLogger
|
||||
def info(message)
|
||||
logger.info(message)
|
||||
end
|
||||
|
||||
def logger
|
||||
@logger ||= Logger.new(STDOUT).tap do |logger|
|
||||
logger.formatter = proc { |severity, _datetime, _progname, msg| "#{severity} #{msg}\n" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace :budgets do
|
||||
desc "Regenerate ballot_lines_count cache"
|
||||
task calculate_ballot_lines: :environment do
|
||||
Budget::Ballot.find_each do |ballot|
|
||||
ApplicationLogger.new.info "Calculating ballot lines"
|
||||
|
||||
Budget::Ballot.find_each.with_index do |ballot, index|
|
||||
Budget::Ballot.reset_counters ballot.id, :lines
|
||||
print "." if (index % 10_000).zero?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
namespace :poll do
|
||||
desc "Generate slugs polls"
|
||||
task generate_slugs: :environment do
|
||||
ApplicationLogger.new.info "Generating poll slugs"
|
||||
|
||||
Poll.find_each do |poll|
|
||||
poll.update_columns(slug: poll.generate_slug, updated_at: Time.current) if poll.generate_slug?
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ namespace :settings do
|
||||
|
||||
desc "Remove deprecated settings"
|
||||
task remove_deprecated_settings: :environment do
|
||||
ApplicationLogger.new.info "Removing deprecated settings"
|
||||
|
||||
deprecated_keys = [
|
||||
"place_name",
|
||||
"banner-style.banner-style-one",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
namespace :stats do
|
||||
desc "Generates stats which are not cached yet"
|
||||
task generate: :environment do
|
||||
ApplicationLogger.new.info "Updating budget and poll stats"
|
||||
|
||||
Budget.find_each do |budget|
|
||||
Budget::Stats.new(budget).generate
|
||||
print "."
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace :stats_and_results do
|
||||
desc "Migrates stats_enabled and results_enabled data to enabled reports"
|
||||
task migrate_to_reports: :environment do
|
||||
ApplicationLogger.new.info "Migrating stats and results"
|
||||
Migrations::Reports.new.migrate
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user