Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AJUSTE_POR_DEFECTO = {
- 'hori' => 329,
- 'vert' => 234,
- 'alta' => 20,
- 'gain' => 1,
- 'ecuacion' => 'x',
- 'A0' => 0.5601496,
- 'A1' => -0.00650881,
- 'A2' => 4.161336e-05,
- 'A3' => -1.499023e-07,
- 'A4' => 2.184775e-10,
- 'E' => 1,
- }
- Equipo.where(tipo_equipo_id: TipoEquipo.select(:id).activos.where("nombre LIKE 'Alineador de luces%'").map(&:id)).each do |e|
- next unless e.otra_informacion['protocolo'].blank? || e.otra_informacion['protocolo'].downcase == 'tecnimaq'
- ajuste = e.valores_ajuste || {}
- next if ajuste['p+6y']
- p5 = ajuste.delete('p+5')
- ajuste.delete('dist_i')
- new_ajuste = {}
- AJUSTE_POR_DEFECTO.each do |key, value|
- new_ajuste[key] = ajuste[key] || value
- end
- new_ajuste['p+6y'] = p5 ? p5 : [10, new_ajuste['vert'] + 60].max
- new_ajuste['p+6x'] = [470, new_ajuste['hori'] + 60].min
- new_ajuste['p-6y'] = [10, 2 * new_ajuste['vert'] - new_ajuste['p+6y']].max
- new_ajuste['p-6x'] = [10, new_ajuste['hori'] - 60].max
- e.ajuste = new_ajuste.to_json
- e.save
- end
Advertisement
Add Comment
Please, Sign In to add comment