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 calculation :: Filter rates by need #12885

Merged
merged 3 commits into from
Jan 5, 2017

Conversation

isimluk
Copy link
Member

@isimluk isimluk commented Nov 28, 2016

Let's use only those ChargebackRateDetails that are needed by calculated report.

In the database we always store all the rate_details. This is first step to get away of them, first we stop using them for calculation, then we can drop them.

We need report_cols in the chargeback anyway, to properly implement charging per dynamic storage types.

As a side effect we will get performance boost.

@miq-bot add_label wip, chargeback, refactoring, euwe/no
@miq-bot assign @gtanzillo

@@ -225,6 +229,10 @@ def contiguous_tiers?

private

def gratis?
chargeback_tiers.all?(&:gratis?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just note: when first tier is gratis, there are no other tiers.
So chargeback_tiers.first.gratis? should be is enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.

Although, that's only true for ChargebackTiers that have been saved after the validation was introduced. The validation check for this is not here from day 1 I think.

Anyway, I prefer this way for readability reasons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I agree, it is more readable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gratis? is a nice touch

@isimluk isimluk force-pushed the filter-rates-by-need branch 2 times, most recently from 92cce5d to 1701ad2 Compare November 30, 2016 09:37
@miq-bot
Copy link
Member

miq-bot commented Nov 30, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@isimluk isimluk changed the title [WIP] Chargeback calculation :: Filter rates by need Chargeback calculation :: Filter rates by need Dec 7, 2016
@isimluk
Copy link
Member Author

isimluk commented Dec 7, 2016

@miq-bot remove_label wip

results, ext = klass.send(custom_results_method, db_options[:options].merge(:userid => options[:userid], :ext_options => ext_options))
results, ext = klass.send(custom_results_method, db_options[:options].merge(:userid => options[:userid],
:ext_options => ext_options,
:report_cols => cols))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this.

Just a side note / thought:

at one time, :report_cols was part of :ext_options. Unfortunately, :ext_options has been abused for too long and we were making it go away (albeit slowly).

Can we use :select or something else that is part of active record's current framework? (Yes, I know this is not an active record call)

@miq-bot
Copy link
Member

miq-bot commented Jan 3, 2017

Checked commits isimluk/manageiq@baef8fd~...64cbb70 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
6 files checked, 0 offenses detected
Everything looks good. 🍪

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looking forward to seeing how this goes

@isimluk
Copy link
Member Author

isimluk commented Jan 5, 2017

Thanks!!

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gtanzillo gtanzillo added this to the Sprint 52 Ending Jan 16, 2017 milestone Jan 5, 2017
@gtanzillo gtanzillo merged commit 0019f07 into ManageIQ:master Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants