Use double quotes in lib/

This commit is contained in:
Julian Herrero
2019-03-15 09:28:48 +01:00
parent c9cdc72537
commit 002e16ce30
15 changed files with 69 additions and 69 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
require 'open-uri'
require "open-uri"
class SMSApi
attr_accessor :client

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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