Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chargeback: Fix rate adjustment rounding bug #13331

Merged
merged 11 commits into from
Jan 23, 2017

Commits on Jan 20, 2017

  1. Simplify math

    This is teached in 7th or 8th grade, so backend developers shall
    comprehend.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    839660c View commit details
    Browse the repository at this point in the history
  2. The adjustment measure is not dependent on the value

    The adjustment is function of two units. It is not function of a value.
    It is independent. It does not depend on each other. The value does not
    affect the adjustment measure.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    70dada9 View commit details
    Browse the repository at this point in the history
  3. Extract common value out of parenthesis

    Like they do in algebra classes.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    597f528 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f4b514a View commit details
    Browse the repository at this point in the history
  5. Refactor: replace switch statement with hash

    Hash can be re-used as it refers to what MetricRollup table contains.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    cf64ee9 View commit details
    Browse the repository at this point in the history
  6. Rate adjustment should not depend on metric_value

    Then we can memoize it and save some time calculating it again and
    again.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    10b3e76 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    217d831 View commit details
    Browse the repository at this point in the history
  8. Use BigDecimal for rate_adjustment calculation

    Float has insufficient precision. Already 1024**-3 causes problems.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    fff5d89 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    76b418a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    943a62e View commit details
    Browse the repository at this point in the history
  11. Workaround buggy version of ruby

    Certain version of ruby (before 2.3.3) have problems with
    
       BigDecimal.new(1) <= Float::INFINITY
    
    or
    
       Float::INFINITY >= BigDecimal.new(1)
    
    Forcing BigDecimal to float in this case will not hurt.
    isimluk committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    bb40e8a View commit details
    Browse the repository at this point in the history