4
I hope you can help me.
I have a Rated who owns evaluations, have several calculations to determine whether or not it will pass an evaluation step.
For example one of these calculations is calcula_pontuacao_minima()
#Cálculo definido pela resolução 1
def calcula_pontuacao_minima(avaliado)
calcula_porcentagem(avaliado.avaliacoes)>60 #onde esta soma todas as notas do avaliado e retorna a porcentagem de aproveitamento
end
My problem here is the appearance of resolutions that alter the calculation, so that all the evaluated before that resolution, must be evaluated for calculations old and new evaluated shall be classified using calculations changed. For example a resolution changes the minimum value to 50%
#Cálculo definido pela resolução 2
def calcula_pontuacao_minima(avaliado)
calcula_porcentagem(avaliado.avaliacoes)>50 #onde esta soma todas as notas do avaliado e retorna a porcentagem de aproveitamento
end
And if in a future they still change to instead of taking the percentage, the minimum value is compared to the total value of the ratings
#Cálculo definido pela resolução 3
def calcula_pontuacao_minima(avaliado)
calcula_total(avaliado.avaliacoes)>70 #onde esta soma todas as notas do avaliado onde o máximo é 120
end
So for example Evaluated which had their evaluations carried out before the date X that defined the resolution 2, will be evaluated by the first calculation after that date X will be evaluated by the second calculus, and after the date Y where the resolution 3, will be evaluated by the third calculation.
Any idea how this can be fixed? It would be a good idea to store the database-level calculations?
All those evaluated before resolution... That were created before resolution or there is some other date field relating to the creation of resolution?
– Felipe Avelar
@Felipeavelar there are fields that will be created after resolution =\
– Luiz Carvalho
Then I’ll add how I would, then you see if the answer fits what you want.
– Felipe Avelar
The calculations will change with what constancy? The user needs to change them or it can be something done by the developer?
– Alex Takitani
@Alextakitani good, utopically the user should change, but I think it is impossible to create something at this level. So it’s a good solution where dev can make this change in a Ruby Like way, it’s already the solution I’m looking for.
– Luiz Carvalho
It is not utopian, with Val is easy to do even, as long as you take care not to let the user enter with dangerous data.
– Alex Takitani
The concept of Strategy exists in Ruby?
– Bruno Augusto