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

[WIP] Allow Fact(s) to be grouped and routed by multiple criteria #40

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

Wedjaa
Copy link

@Wedjaa Wedjaa commented Aug 24, 2016

The concept is quite simple: a Fact may have multiple Keys and can transform - enrich - a Fact based on the Key that's being used.

The Fact class has two changes:

  1. extractKey was changed to extractKeys: this method, rather than returning a single Key will return a Set of one or more keys. It's up to the implementation of the Fact to decide what Key(s) it should return. In the Gameplay example: extractKeys will return two Key(s) - one for Player grouping, that uses the playerId as grouping key, and one for Game grouping, that uses the gameName as grouping key;
  2. a new method forKey was added to the Fact class: the Fact classes implementing this method will decide how to enrich the instance of a Fact depending on the Key value and return the enriched instance. In the Gameplay example: the fact will have a factGroup set to the Key criteria [see below]. This allows the rules to filter duplicate Facts coming their way.

The Key class has one main change: it has a new property - called criteria - that is a label for a specific Key implementation. This change allows the forKey method of the Fact to have some more information about a Key to make an informed decision on what to do about it.

Lastly the Putter class was changed to take advantage of these changes: when a Fact is received it will insert in the Cache one instance of the Fact for every Key returned by extractKeys, transformed by the forKey method.

This is a WIP.

Wedjaa and others added 22 commits August 23, 2016 10:23
Facts that return only one Key are inserted only once, no change. Facts that have multiple Key(s)
 will be reinserted - and redistributed - over the grid multiple times - the rules should check for the
 appropriate keys when processing a Fact to avoid duplication.
This Key will group by game name.
This outcome will keep tabs on the number of times and the amount spent on a game.
A Fact can be transformed depending on a Key value. This means that a Fact implementation could
add a property to the fact to allow the rules to fire depending on the specific group this Fact has
been routed to.
…he Key

forKey has been implemented so that it will return the Fact with a different factGroup depending
on the Key that was passed. This will allow the rules to discriminate based on this criteria.
The criteria property is a description of the criteria used to create this Key. Something in the lines of
"playerId" or "gameName". This will allow a Fact to populate a property with this criteria, so that rules
will be able to trigger on specific Fact(s).
Added a rule - rule3 - to detect a users that is the Nth player for a game in  D days.
Added a rule to collect game playing statistics.
@fmarinelli
Copy link
Contributor

Thanks for your PR, I saw there's a lot of changes compared to master branch.

Are you available sometimes in the future to talk about it?

@Wedjaa
Copy link
Author

Wedjaa commented Aug 25, 2016

I could try and get you on Skype. When are you available.

@ugol
Copy link
Contributor

ugol commented Aug 25, 2016

We are both available now on IRC, channel #drools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants