Skip to content

Instantly share code, notes, and snippets.

@augcesar
Last active December 18, 2015 16:58
Show Gist options
  • Save augcesar/7e18e42160e20395cfb3 to your computer and use it in GitHub Desktop.
Save augcesar/7e18e42160e20395cfb3 to your computer and use it in GitHub Desktop.
antes = []
loa = Loa.find_by(ano:'2016')
tipo_emenda = TipoEmenda.find_by(descricao: "EP/LOM")
FuncionalProgramaticoLoaEmenda.joins(:emenda).where(emendas: {loa_id:loa.id, tipo_emenda_id:tipo_emenda.id },reducao_acrescimo: 'ACRESCIMO').each do |fpl|
if tipo_emenda.descricao.downcase == fpl.subacao.reverse.split('-',2).first.reverse.strip.downcase
subacao_nova = "#{fpl.subacao.reverse.split('-',2).last.reverse.strip} - #{tipo_emenda.descricao}"
else
subacao_nova = "#{fpl.subacao.reverse.split('-',2).join('-').reverse.strip} - #{tipo_emenda.descricao}"
end
antes << {a:fpl.subacao, d:subacao_nova}
fpl.update_column :subacao, subacao_nova
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment