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:
Javi Martín
2019-06-03 16:59:40 +02:00
parent 3ab2085e05
commit 1d0b05832c
6 changed files with 22 additions and 1 deletions

11
lib/application_logger.rb Normal file
View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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",

View File

@@ -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 "."

View File

@@ -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