Use double quotes in lib/
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
namespace :deploy do
|
namespace :deploy do
|
||||||
desc 'Restart Unicorn'
|
desc "Restart Unicorn"
|
||||||
task :restart do
|
task :restart do
|
||||||
on roles(:app) do
|
on roles(:app) do
|
||||||
execute "kill -QUIT `cat /home/deploy/consul/pids/unicorn.pid`; true"
|
execute "kill -QUIT `cat /home/deploy/consul/pids/unicorn.pid`; true"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class CommentTree
|
|||||||
|
|
||||||
attr_accessor :root_comments, :comments, :commentable, :page, :order
|
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
|
@commentable = commentable
|
||||||
@page = page
|
@page = page
|
||||||
@order = order
|
@order = order
|
||||||
@@ -17,7 +17,7 @@ class CommentTree
|
|||||||
end
|
end
|
||||||
|
|
||||||
def base_comments
|
def base_comments
|
||||||
if @valuations && commentable.respond_to?('valuations')
|
if @valuations && commentable.respond_to?("valuations")
|
||||||
commentable.valuations
|
commentable.valuations
|
||||||
else
|
else
|
||||||
commentable.comments
|
commentable.comments
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module DocumentParser
|
|||||||
|
|
||||||
def get_document_number_variants(document_type, document_number)
|
def get_document_number_variants(document_type, document_number)
|
||||||
# Delete all non-alphanumerics
|
# 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 = []
|
variants = []
|
||||||
|
|
||||||
if dni?(document_type)
|
if dni?(document_type)
|
||||||
@@ -34,7 +34,7 @@ module DocumentParser
|
|||||||
# ['1234', '01234', '001234', '0001234']
|
# ['1234', '01234', '001234', '0001234']
|
||||||
def get_number_variants_with_leading_zeroes_from(document_number, digits = 8)
|
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.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 = []
|
||||||
variants << document_number if document_number.present?
|
variants << document_number if document_number.present?
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'graphql'
|
require "graphql"
|
||||||
|
|
||||||
module GraphQL
|
module GraphQL
|
||||||
class ApiTypesCreator
|
class ApiTypesCreator
|
||||||
@@ -65,7 +65,7 @@ module GraphQL
|
|||||||
model = api_type_model.constantize
|
model = api_type_model.constantize
|
||||||
fields = {}
|
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
|
if field_type.is_a?(Array) # paginated association
|
||||||
fields[field_name.to_sym] = [field_type.first.constantize]
|
fields[field_name.to_sym] = [field_type.first.constantize]
|
||||||
elsif SCALAR_TYPES[field_type.to_sym]
|
elsif SCALAR_TYPES[field_type.to_sym]
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
require 'graphql'
|
require "graphql"
|
||||||
|
|
||||||
module GraphQL
|
module GraphQL
|
||||||
class QueryTypeCreator
|
class QueryTypeCreator
|
||||||
|
|
||||||
def self.create(api_types)
|
def self.create(api_types)
|
||||||
GraphQL::ObjectType.define do
|
GraphQL::ObjectType.define do
|
||||||
name 'QueryType'
|
name "QueryType"
|
||||||
description 'The root query for the schema'
|
description "The root query for the schema"
|
||||||
|
|
||||||
api_types.each do |model, created_type|
|
api_types.each do |model, created_type|
|
||||||
if created_type.fields['id']
|
if created_type.fields["id"]
|
||||||
field model.graphql_field_name do
|
field model.graphql_field_name do
|
||||||
type created_type
|
type created_type
|
||||||
description model.graphql_field_description
|
description model.graphql_field_description
|
||||||
argument :id, !types.ID
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class MergedCommentTree < CommentTree
|
class MergedCommentTree < CommentTree
|
||||||
attr_accessor :commentables, :array_order
|
attr_accessor :commentables, :array_order
|
||||||
|
|
||||||
def initialize(commentables, page, order = 'confidence_score')
|
def initialize(commentables, page, order = "confidence_score")
|
||||||
@commentables = commentables
|
@commentables = commentables
|
||||||
@commentable = commentables.first
|
@commentable = commentables.first
|
||||||
@page = page
|
@page = page
|
||||||
|
|||||||
@@ -9,20 +9,20 @@ class MigrateSpendingProposalsToInvestments
|
|||||||
if sp.geozone_id.present?
|
if sp.geozone_id.present?
|
||||||
group = budget.groups.find_or_create_by!(name: "Barrios")
|
group = budget.groups.find_or_create_by!(name: "Barrios")
|
||||||
heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000,
|
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
|
else
|
||||||
group = budget.groups.find_or_create_by!(name: "Toda la ciudad")
|
group = budget.groups.find_or_create_by!(name: "Toda la ciudad")
|
||||||
heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000,
|
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
|
end
|
||||||
|
|
||||||
feasibility = case sp.feasible
|
feasibility = case sp.feasible
|
||||||
when FalseClass
|
when FalseClass
|
||||||
'unfeasible'
|
"unfeasible"
|
||||||
when TrueClass
|
when TrueClass
|
||||||
'feasible'
|
"feasible"
|
||||||
else
|
else
|
||||||
'undecided'
|
"undecided"
|
||||||
end
|
end
|
||||||
|
|
||||||
investment = Budget::Investment.create!(
|
investment = Budget::Investment.create!(
|
||||||
@@ -49,14 +49,14 @@ class MigrateSpendingProposalsToInvestments
|
|||||||
|
|
||||||
investment.valuators = sp.valuation_assignments.map(&:valuator)
|
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
|
# Spending proposals are not commentable in Consul so we can not test this
|
||||||
#
|
#
|
||||||
# Comment.where(commentable_type: 'SpendingProposal', commentable_id: sp.id).update_all(
|
# Comment.where(commentable_type: "SpendingProposal", commentable_id: sp.id).update_all(
|
||||||
# commentable_type: 'Budget::Investment', commentable_id: investment.id
|
# commentable_type: "Budget::Investment", commentable_id: investment.id
|
||||||
# )
|
# )
|
||||||
# Budget::Investment.reset_counters(investment.id, :comments)
|
# Budget::Investment.reset_counters(investment.id, :comments)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module ScoreCalculator
|
|||||||
return 0 unless resource.created_at
|
return 0 unless resource.created_at
|
||||||
|
|
||||||
period = [
|
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
|
((Time.current - resource.created_at) / 1.day).ceil
|
||||||
].min
|
].min
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'open-uri'
|
require "open-uri"
|
||||||
class SMSApi
|
class SMSApi
|
||||||
attr_accessor :client
|
attr_accessor :client
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ namespace :homepage do
|
|||||||
%w(proposals debates processes).each do |kind|
|
%w(proposals debates processes).each do |kind|
|
||||||
Widget::Feed.create(kind: kind)
|
Widget::Feed.create(kind: kind)
|
||||||
|
|
||||||
Setting['feature.homepage.widgets.feeds.proposals'] = true
|
Setting["feature.homepage.widgets.feeds.proposals"] = true
|
||||||
Setting['feature.homepage.widgets.feeds.debates'] = true
|
Setting["feature.homepage.widgets.feeds.debates"] = true
|
||||||
Setting['feature.homepage.widgets.feeds.processes'] = true
|
Setting["feature.homepage.widgets.feeds.processes"] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
namespace :locales do
|
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|
|
task :migrate_structure, [:locale] => [:environment] do |_t, args|
|
||||||
locale = args[:locale]
|
locale = args[:locale]
|
||||||
puts "Moving files for locale: #{locale}"
|
puts "Moving files for locale: #{locale}"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
namespace :map_locations do
|
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
|
task destroy: :environment do
|
||||||
MapLocation.where(longitude: nil, latitude: nil, zoom: nil).each do |map_location|
|
MapLocation.where(longitude: nil, latitude: nil, zoom: nil).each do |map_location|
|
||||||
map_location.destroy
|
map_location.destroy
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
namespace :milestones do
|
namespace :milestones do
|
||||||
|
|
||||||
def generate_table_migration_sql(new_table:, old_table:, columns:)
|
def generate_table_migration_sql(new_table:, old_table:, columns:)
|
||||||
from_cols = ['id', *columns.keys]
|
from_cols = ["id", *columns.keys]
|
||||||
to_cols = ['id', *columns.values]
|
to_cols = ["id", *columns.values]
|
||||||
<<~SQL
|
<<~SQL
|
||||||
INSERT INTO #{new_table} (#{to_cols.join(', ')})
|
INSERT INTO #{new_table} (#{to_cols.join(", ")})
|
||||||
SELECT #{from_cols.join(', ')} FROM #{old_table};
|
SELECT #{from_cols.join(", ")} FROM #{old_table};
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -48,36 +48,36 @@ namespace :milestones do
|
|||||||
start = Time.now
|
start = Time.now
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
migrate_table! old_table: 'budget_investment_statuses',
|
migrate_table! old_table: "budget_investment_statuses",
|
||||||
new_table: 'milestone_statuses',
|
new_table: "milestone_statuses",
|
||||||
columns: {'name' => 'name',
|
columns: {"name" => "name",
|
||||||
'description' => 'description',
|
"description" => "description",
|
||||||
'hidden_at' => 'hidden_at',
|
"hidden_at" => "hidden_at",
|
||||||
'created_at' => 'created_at',
|
"created_at" => "created_at",
|
||||||
'updated_at' => 'updated_at'}
|
"updated_at" => "updated_at"}
|
||||||
|
|
||||||
migrate_table! old_table: 'budget_investment_milestones',
|
migrate_table! old_table: "budget_investment_milestones",
|
||||||
new_table: 'milestones',
|
new_table: "milestones",
|
||||||
columns: {'investment_id' => 'milestoneable_id',
|
columns: {"investment_id" => "milestoneable_id",
|
||||||
'title' => 'title',
|
"title" => "title",
|
||||||
'description' => 'description',
|
"description" => "description",
|
||||||
'created_at' => 'created_at',
|
"created_at" => "created_at",
|
||||||
'updated_at' => 'updated_at',
|
"updated_at" => "updated_at",
|
||||||
'publication_date' => 'publication_date',
|
"publication_date" => "publication_date",
|
||||||
'status_id' => 'status_id'}
|
"status_id" => "status_id"}
|
||||||
|
|
||||||
populate_column! table: 'milestones',
|
populate_column! table: "milestones",
|
||||||
column: 'milestoneable_type',
|
column: "milestoneable_type",
|
||||||
value: 'Budget::Investment'
|
value: "Budget::Investment"
|
||||||
|
|
||||||
migrate_table! old_table: 'budget_investment_milestone_translations',
|
migrate_table! old_table: "budget_investment_milestone_translations",
|
||||||
new_table: 'milestone_translations',
|
new_table: "milestone_translations",
|
||||||
columns: {'budget_investment_milestone_id' => 'milestone_id',
|
columns: {"budget_investment_milestone_id" => "milestone_id",
|
||||||
'locale' => 'locale',
|
"locale" => "locale",
|
||||||
'created_at' => 'created_at',
|
"created_at" => "created_at",
|
||||||
'updated_at' => 'updated_at',
|
"updated_at" => "updated_at",
|
||||||
'title' => 'title',
|
"title" => "title",
|
||||||
'description' => 'description'}
|
"description" => "description"}
|
||||||
|
|
||||||
Image.where(imageable_type: "Budget::Investment::Milestone").
|
Image.where(imageable_type: "Budget::Investment::Milestone").
|
||||||
update_all(imageable_type: "Milestone")
|
update_all(imageable_type: "Milestone")
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
namespace :web_sections do
|
namespace :web_sections do
|
||||||
desc "Generate web sections for banners"
|
desc "Generate web sections for banners"
|
||||||
task generate: :environment do
|
task generate: :environment do
|
||||||
WebSection.create(name: 'homepage')
|
WebSection.create(name: "homepage")
|
||||||
WebSection.create(name: 'debates')
|
WebSection.create(name: "debates")
|
||||||
WebSection.create(name: 'proposals')
|
WebSection.create(name: "proposals")
|
||||||
WebSection.create(name: 'budgets')
|
WebSection.create(name: "budgets")
|
||||||
WebSection.create(name: 'help_page')
|
WebSection.create(name: "help_page")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ class UserSegments
|
|||||||
def self.not_supported_on_current_budget
|
def self.not_supported_on_current_budget
|
||||||
author_ids(
|
author_ids(
|
||||||
User.where(
|
User.where(
|
||||||
'id NOT IN (SELECT DISTINCT(voter_id) FROM votes'\
|
"id NOT IN (SELECT DISTINCT(voter_id) FROM votes"\
|
||||||
' WHERE votable_type = ? AND votes.votable_id IN (?))',
|
" WHERE votable_type = ? AND votes.votable_id IN (?))",
|
||||||
'Budget::Investment',
|
"Budget::Investment",
|
||||||
current_budget_investments.pluck(:id)
|
current_budget_investments.pluck(:id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user