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

Fix RatesQuery#rates method to respect relevant_date argument #2399

Merged
merged 3 commits into from
Mar 30, 2016

Conversation

erkde
Copy link
Contributor

@erkde erkde commented Mar 22, 2016

There seems to be a subtle bug in this code, in that the query class saves the results of invoking #rates the first time in a @rates instance variable.

But on subsequent invocations, it returns the previously calculated value, regardless if it is invoked with a different relevant_date argument.

@erkde erkde force-pushed the fix_rates_query_rates branch from d026c95 to bc716c3 Compare March 23, 2016 12:24
@erkde erkde added the bug Something isn't working label Mar 23, 2016
@chrisroos
Copy link
Contributor

Was commit ed1e6fe (titled "Rename rates local shadowing enclosing method name") necessary? Or was it more of a good practice change?

Aside from my question, this all looks good to me.

@chrisroos chrisroos self-assigned this Mar 26, 2016
@chrisroos chrisroos added the LGTM label Mar 26, 2016
@erkde
Copy link
Contributor Author

erkde commented Mar 28, 2016

@chrisroos - I don't think it is necessary, just my preference given the enclosing method signature is the same as the local variable, when called without an argument (using the default value). I just checked the shadowing lint in Rubocop and it seems like it doesn't apply, so can probably be safely removed from the PR.

@erkde
Copy link
Contributor Author

erkde commented Mar 28, 2016

Btw, I'm can no longer merge my PR's, not even sure about pushing a rebase of my branches to alphagov. Let me know if you want me to help with my remaining open ones via a fork.

@chrisroos
Copy link
Contributor

Thanks for clarifying, @erikse. I'm happy for the first commit to remain, I was simply interested in the motivation.

I'll get this rebased and merged shortly.

erkde added 3 commits March 30, 2016 19:18
Caching @rates with the first calculated result doesn’t allow for
the #rates method to return correct values for alternate dates.

As the #data method has its own memoization of the YAML file content
after being invoked the first time, searching through the contents on
subsequent invocations of #rates hopefully isn’t too costly.
This class is used by several smart answers, so I’m not sure why its
file checksum is tracked for this smart answer particularly.
@chrisroos chrisroos force-pushed the fix_rates_query_rates branch from bc716c3 to 1ba86a1 Compare March 30, 2016 06:26
@chrisroos
Copy link
Contributor

I've rebased this on master and force pushed in preparation for merging. I was happy to force push as there were no comments on individual commits that would be lost.

@erkde
Copy link
Contributor Author

erkde commented Mar 30, 2016

Cool, thanks for the help merging

On Wednesday, 30 March 2016, Chris Roos notifications@github.com wrote:

I've rebased this on master and force pushed in preparation for merging. I
was happy to force push as there were no comments on individual commits
that would be lost.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#2399 (comment)

Sent from Gmail Mobile

@chrisroos chrisroos merged commit b322f5a into master Mar 30, 2016
@chrisroos chrisroos deleted the fix_rates_query_rates branch March 30, 2016 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants