somerandomsequence/food-rescue-robot — pull request #7 by zedoyle (2014-02-19 23:53:42+00:00)
Title: Regionally-controlled scales, unit conversion

Copied from the latest commit desc.:

*This is the final implementation of regionally-selectable scales. A new migration file, init_scale_types, will create "Guesstimate scales" for each region, which measure in pounds - this made more sense to me than a separate flippable bit for guesstimates. In order to use actual scales, regional administrators should go to the new Scale Types tab under their menu bar section and create a new scale for the appropriate weight unit. Log_parts are associated with the scale their owner log was measured with, which should make data analysis fairly painless.*

*Unit conversions are relatively rough, and could definitely be refined - at the moment kg and st are converted to lb with a floating point multiplicative operation and then cast to an int; I don't think this will create a serious amount of error, but I could definitely be wrong there. If it's a problem I'll go in and tinker with them.*

*The conversions themselves happen at the log-part level; since the values present on the edit-form view for logs are the converted values, the edit action DOES NOT run the conversion a second time (this would very quickly reduce your average ~4-5 lb item to 0lb). If this becomes an issue I think it would be somewhat easy to check to see if the scale was changed from its original, and run the conversion then, but that seems pretty unnecessary to me.*

*If I get the chance, I'd like to add an attribute signifying a given scale's degree of precision - currently, there's no real reason for a region to have multiple (non-guesstimate) scales asside from mixing their weight units.*