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

Cashflow example and rule retraction #268

Closed
mgilbir opened this issue Nov 23, 2021 · 3 comments
Closed

Cashflow example and rule retraction #268

mgilbir opened this issue Nov 23, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@mgilbir
Copy link

mgilbir commented Nov 23, 2021

Describe the bug
When I run the cashflow example the result doesn't reflect what logically the test example is trying to showcase: that you can have another object to accumulate output from multiple runs.
When the SumUpPurchase rule is retracted, it is effectively forcing that only the first purchase is accumulated in the CashFlow object.

To Reproduce
Run go test examples -run TestCashFlowCalculator_CalculatePurchases -v

There are 11 purchases passed but the cashflow object string output that is the test result shows:

=== RUN   TestCashFlowCalculator_CalculatePurchases
Purchase count 1 total amount 100000.000000. Total tax are 115000.000000 thus total cash in 215000.000000

Expected behavior
The cashflow object to reflect the multiple purchases that have been processed.

newm4n added a commit to newm4n/grule-rule-engine that referenced this issue Nov 25, 2021
…e same knowledgebase instance, the rule entries are not resetted as intended.
@newm4n newm4n self-assigned this Nov 25, 2021
@newm4n newm4n added the bug Something isn't working label Nov 25, 2021
@newm4n
Copy link
Member

newm4n commented Nov 25, 2021

This is really odd, and strangely afterall this time, this never caught by anybody. Thanks a lot @mgilbir .
This is due to whenever the engine start using previously used KnowledgeBase, it never reset all retracted rules.
The function is already created to reset all retracted rules, but some how, never called.

I've made an adjustment in my branch, and its ok now. About to PR it.

newm4n added a commit that referenced this issue Nov 25, 2021
* Fixed issue #268 where everytime engine execute using the same knowledgebase instance, the rule entries are not resetted as intended.

* Addjust pipeline to run golint

* I temporary removed golint in the test, need to figure out how pipeline install golint into GOBIN
@newm4n
Copy link
Member

newm4n commented Nov 25, 2021

@mgilbir
Copy link
Author

mgilbir commented Nov 25, 2021

Confirmed that it works now. Thanks for the quick fix!

@mgilbir mgilbir closed this as completed Nov 25, 2021
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

No branches or pull requests

2 participants