diff --git a/lib/capistrano/tasks/restart.cap b/lib/capistrano/tasks/restart.cap index 30740e3a7..17e1e57db 100644 --- a/lib/capistrano/tasks/restart.cap +++ b/lib/capistrano/tasks/restart.cap @@ -1,5 +1,5 @@ namespace :deploy do - desc 'Restart Unicorn' + desc "Restart Unicorn" task :restart do on roles(:app) do execute "kill -QUIT `cat /home/deploy/consul/pids/unicorn.pid`; true" diff --git a/lib/comment_tree.rb b/lib/comment_tree.rb index a67a0ccc3..f43ab7e40 100644 --- a/lib/comment_tree.rb +++ b/lib/comment_tree.rb @@ -4,7 +4,7 @@ class CommentTree attr_accessor :root_comments, :comments, :commentable, :page, :order - def initialize(commentable, page, order = 'confidence_score', valuations: false) + def initialize(commentable, page, order = "confidence_score", valuations: false) @commentable = commentable @page = page @order = order @@ -17,7 +17,7 @@ class CommentTree end def base_comments - if @valuations && commentable.respond_to?('valuations') + if @valuations && commentable.respond_to?("valuations") commentable.valuations else commentable.comments diff --git a/lib/document_parser.rb b/lib/document_parser.rb index 9e59c6b75..8e043dd20 100644 --- a/lib/document_parser.rb +++ b/lib/document_parser.rb @@ -2,7 +2,7 @@ module DocumentParser def get_document_number_variants(document_type, document_number) # Delete all non-alphanumerics - document_number = document_number.to_s.gsub(/[^0-9A-Za-z]/i, '') + document_number = document_number.to_s.gsub(/[^0-9A-Za-z]/i, "") variants = [] if dni?(document_type) @@ -34,7 +34,7 @@ module DocumentParser # ['1234', '01234', '001234', '0001234'] def get_number_variants_with_leading_zeroes_from(document_number, digits = 8) document_number = document_number.to_s.last(digits) # Keep only the last x digits - document_number = document_number.gsub(/^0+/, '') # Removes leading zeros + document_number = document_number.gsub(/^0+/, "") # Removes leading zeros variants = [] variants << document_number if document_number.present? diff --git a/lib/graph_ql/api_types_creator.rb b/lib/graph_ql/api_types_creator.rb index 9f55be3cc..b7cb6c369 100644 --- a/lib/graph_ql/api_types_creator.rb +++ b/lib/graph_ql/api_types_creator.rb @@ -1,4 +1,4 @@ -require 'graphql' +require "graphql" module GraphQL class ApiTypesCreator @@ -65,7 +65,7 @@ module GraphQL model = api_type_model.constantize fields = {} - api_type_info['fields'].each do |field_name, field_type| + api_type_info["fields"].each do |field_name, field_type| if field_type.is_a?(Array) # paginated association fields[field_name.to_sym] = [field_type.first.constantize] elsif SCALAR_TYPES[field_type.to_sym] diff --git a/lib/graph_ql/query_type_creator.rb b/lib/graph_ql/query_type_creator.rb index 8f4a497ef..d0c216bcf 100644 --- a/lib/graph_ql/query_type_creator.rb +++ b/lib/graph_ql/query_type_creator.rb @@ -1,20 +1,20 @@ -require 'graphql' +require "graphql" module GraphQL class QueryTypeCreator def self.create(api_types) GraphQL::ObjectType.define do - name 'QueryType' - description 'The root query for the schema' + name "QueryType" + description "The root query for the schema" api_types.each do |model, created_type| - if created_type.fields['id'] + if created_type.fields["id"] field model.graphql_field_name do type created_type description model.graphql_field_description argument :id, !types.ID - resolve ->(object, arguments, context) { model.public_for_api.find_by(id: arguments['id'])} + resolve ->(object, arguments, context) { model.public_for_api.find_by(id: arguments["id"])} end end diff --git a/lib/merged_comment_tree.rb b/lib/merged_comment_tree.rb index b6a1c97aa..30bacbaf8 100644 --- a/lib/merged_comment_tree.rb +++ b/lib/merged_comment_tree.rb @@ -1,7 +1,7 @@ class MergedCommentTree < CommentTree attr_accessor :commentables, :array_order - def initialize(commentables, page, order = 'confidence_score') + def initialize(commentables, page, order = "confidence_score") @commentables = commentables @commentable = commentables.first @page = page @@ -25,4 +25,4 @@ class MergedCommentTree < CommentTree end end -end \ No newline at end of file +end diff --git a/lib/migrate_spending_proposals_to_investments.rb b/lib/migrate_spending_proposals_to_investments.rb index 7983c547e..f8261ade2 100644 --- a/lib/migrate_spending_proposals_to_investments.rb +++ b/lib/migrate_spending_proposals_to_investments.rb @@ -9,20 +9,20 @@ class MigrateSpendingProposalsToInvestments if sp.geozone_id.present? group = budget.groups.find_or_create_by!(name: "Barrios") heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000, - latitude: '40.416775', longitude: '-3.703790') + latitude: "40.416775", longitude: "-3.703790") else group = budget.groups.find_or_create_by!(name: "Toda la ciudad") heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000, - latitude: '40.416775', longitude: '-3.703790') + latitude: "40.416775", longitude: "-3.703790") end feasibility = case sp.feasible when FalseClass - 'unfeasible' + "unfeasible" when TrueClass - 'feasible' + "feasible" else - 'undecided' + "undecided" end investment = Budget::Investment.create!( @@ -49,14 +49,14 @@ class MigrateSpendingProposalsToInvestments investment.valuators = sp.valuation_assignments.map(&:valuator) - votes = ActsAsVotable::Vote.where(votable_type: 'SpendingProposal', votable_id: sp.id) + votes = ActsAsVotable::Vote.where(votable_type: "SpendingProposal", votable_id: sp.id) - votes.each {|v| investment.vote_by(voter: v.voter, vote: 'yes') } + votes.each {|v| investment.vote_by(voter: v.voter, vote: "yes") } # Spending proposals are not commentable in Consul so we can not test this # - # Comment.where(commentable_type: 'SpendingProposal', commentable_id: sp.id).update_all( - # commentable_type: 'Budget::Investment', commentable_id: investment.id + # Comment.where(commentable_type: "SpendingProposal", commentable_id: sp.id).update_all( + # commentable_type: "Budget::Investment", commentable_id: investment.id # ) # Budget::Investment.reset_counters(investment.id, :comments) diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb index df40428f8..bfe91c29c 100644 --- a/lib/score_calculator.rb +++ b/lib/score_calculator.rb @@ -4,7 +4,7 @@ module ScoreCalculator return 0 unless resource.created_at period = [ - Setting['hot_score_period_in_days'].to_i, + Setting["hot_score_period_in_days"].to_i, ((Time.current - resource.created_at) / 1.day).ceil ].min diff --git a/lib/sms_api.rb b/lib/sms_api.rb index 252d0749e..69a0d93a1 100644 --- a/lib/sms_api.rb +++ b/lib/sms_api.rb @@ -1,4 +1,4 @@ -require 'open-uri' +require "open-uri" class SMSApi attr_accessor :client diff --git a/lib/tasks/homepage.rake b/lib/tasks/homepage.rake index f48bd71ff..0a479adf0 100644 --- a/lib/tasks/homepage.rake +++ b/lib/tasks/homepage.rake @@ -5,9 +5,9 @@ namespace :homepage do %w(proposals debates processes).each do |kind| Widget::Feed.create(kind: kind) - Setting['feature.homepage.widgets.feeds.proposals'] = true - Setting['feature.homepage.widgets.feeds.debates'] = true - Setting['feature.homepage.widgets.feeds.processes'] = true + Setting["feature.homepage.widgets.feeds.proposals"] = true + Setting["feature.homepage.widgets.feeds.debates"] = true + Setting["feature.homepage.widgets.feeds.processes"] = true end end end diff --git a/lib/tasks/locales.rake b/lib/tasks/locales.rake index 8448b4003..e7983df42 100644 --- a/lib/tasks/locales.rake +++ b/lib/tasks/locales.rake @@ -1,5 +1,5 @@ namespace :locales do - desc 'Migrate all localization files to new structure for a given locale name as argument' + desc "Migrate all localization files to new structure for a given locale name as argument" task :migrate_structure, [:locale] => [:environment] do |_t, args| locale = args[:locale] puts "Moving files for locale: #{locale}" diff --git a/lib/tasks/map_locations.rake b/lib/tasks/map_locations.rake index b204be2c7..63dc5d0d0 100644 --- a/lib/tasks/map_locations.rake +++ b/lib/tasks/map_locations.rake @@ -1,5 +1,5 @@ namespace :map_locations do - desc 'Destroy all empty MapLocation instances found in the database' + desc "Destroy all empty MapLocation instances found in the database" task destroy: :environment do MapLocation.where(longitude: nil, latitude: nil, zoom: nil).each do |map_location| map_location.destroy diff --git a/lib/tasks/migrate_milestones_and_statuses.rake b/lib/tasks/migrate_milestones_and_statuses.rake index d01418e6b..6b95f860c 100644 --- a/lib/tasks/migrate_milestones_and_statuses.rake +++ b/lib/tasks/migrate_milestones_and_statuses.rake @@ -1,11 +1,11 @@ namespace :milestones do def generate_table_migration_sql(new_table:, old_table:, columns:) - from_cols = ['id', *columns.keys] - to_cols = ['id', *columns.values] + from_cols = ["id", *columns.keys] + to_cols = ["id", *columns.values] <<~SQL - INSERT INTO #{new_table} (#{to_cols.join(', ')}) - SELECT #{from_cols.join(', ')} FROM #{old_table}; + INSERT INTO #{new_table} (#{to_cols.join(", ")}) + SELECT #{from_cols.join(", ")} FROM #{old_table}; SQL end @@ -48,36 +48,36 @@ namespace :milestones do start = Time.now ActiveRecord::Base.transaction do - migrate_table! old_table: 'budget_investment_statuses', - new_table: 'milestone_statuses', - columns: {'name' => 'name', - 'description' => 'description', - 'hidden_at' => 'hidden_at', - 'created_at' => 'created_at', - 'updated_at' => 'updated_at'} + migrate_table! old_table: "budget_investment_statuses", + new_table: "milestone_statuses", + columns: {"name" => "name", + "description" => "description", + "hidden_at" => "hidden_at", + "created_at" => "created_at", + "updated_at" => "updated_at"} - migrate_table! old_table: 'budget_investment_milestones', - new_table: 'milestones', - columns: {'investment_id' => 'milestoneable_id', - 'title' => 'title', - 'description' => 'description', - 'created_at' => 'created_at', - 'updated_at' => 'updated_at', - 'publication_date' => 'publication_date', - 'status_id' => 'status_id'} + migrate_table! old_table: "budget_investment_milestones", + new_table: "milestones", + columns: {"investment_id" => "milestoneable_id", + "title" => "title", + "description" => "description", + "created_at" => "created_at", + "updated_at" => "updated_at", + "publication_date" => "publication_date", + "status_id" => "status_id"} - populate_column! table: 'milestones', - column: 'milestoneable_type', - value: 'Budget::Investment' + populate_column! table: "milestones", + column: "milestoneable_type", + value: "Budget::Investment" - migrate_table! old_table: 'budget_investment_milestone_translations', - new_table: 'milestone_translations', - columns: {'budget_investment_milestone_id' => 'milestone_id', - 'locale' => 'locale', - 'created_at' => 'created_at', - 'updated_at' => 'updated_at', - 'title' => 'title', - 'description' => 'description'} + migrate_table! old_table: "budget_investment_milestone_translations", + new_table: "milestone_translations", + columns: {"budget_investment_milestone_id" => "milestone_id", + "locale" => "locale", + "created_at" => "created_at", + "updated_at" => "updated_at", + "title" => "title", + "description" => "description"} Image.where(imageable_type: "Budget::Investment::Milestone"). update_all(imageable_type: "Milestone") diff --git a/lib/tasks/web_sections.rake b/lib/tasks/web_sections.rake index a3e5a4b25..159be63e1 100644 --- a/lib/tasks/web_sections.rake +++ b/lib/tasks/web_sections.rake @@ -1,10 +1,10 @@ namespace :web_sections do desc "Generate web sections for banners" task generate: :environment do - WebSection.create(name: 'homepage') - WebSection.create(name: 'debates') - WebSection.create(name: 'proposals') - WebSection.create(name: 'budgets') - WebSection.create(name: 'help_page') + WebSection.create(name: "homepage") + WebSection.create(name: "debates") + WebSection.create(name: "proposals") + WebSection.create(name: "budgets") + WebSection.create(name: "help_page") end end diff --git a/lib/user_segments.rb b/lib/user_segments.rb index 7bbc8668c..045f558a0 100644 --- a/lib/user_segments.rb +++ b/lib/user_segments.rb @@ -41,9 +41,9 @@ class UserSegments def self.not_supported_on_current_budget author_ids( User.where( - 'id NOT IN (SELECT DISTINCT(voter_id) FROM votes'\ - ' WHERE votable_type = ? AND votes.votable_id IN (?))', - 'Budget::Investment', + "id NOT IN (SELECT DISTINCT(voter_id) FROM votes"\ + " WHERE votable_type = ? AND votes.votable_id IN (?))", + "Budget::Investment", current_budget_investments.pluck(:id) ) )