You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by GitBox <gi...@apache.org> on 2021/11/18 06:18:01 UTC

[GitHub] [unomi] dgriffon opened a new pull request #363: UNOMI-530 : fix maximumEventCount in past event condition

dgriffon opened a new pull request #363:
URL: https://github.com/apache/unomi/pull/363


   https://issues.apache.org/jira/browse/UNOMI-530
   
   Covered by integration test.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] dgriffon commented on a change in pull request #363: UNOMI-530 : fix maximumEventCount in past event condition

Posted by GitBox <gi...@apache.org>.
dgriffon commented on a change in pull request #363:
URL: https://github.com/apache/unomi/pull/363#discussion_r751957805



##########
File path: itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
##########
@@ -358,4 +360,100 @@ public void testScoringPastEventRecalculation() throws Exception {
                 updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test"),
                 1000, 20);
     }
+
+
+    @Test
+    public void testScoringRecalculation() throws Exception {
+        // create Profile
+        Profile profile = new Profile();
+        profile.setItemId("test_profile_id");
+        profileService.save(profile);
+        persistenceService.refreshIndex(Profile.class, null); // wait for profile to be full persisted and index
+
+        Date timestampEventInRange = new SimpleDateFormat("yyyy-MM-dd").parse("2000-10-30");
+        // create the past event condition
+        Condition pastEventCondition = new Condition(definitionsService.getConditionType("pastEventCondition"));
+        pastEventCondition.setParameter("minimumEventCount", 1);
+        pastEventCondition.setParameter("maximumEventCount", 2);
+
+        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");;
+        Condition pastEventEventCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
+        pastEventEventCondition.setParameter("eventTypeId", "test-event-type");
+        pastEventCondition.setParameter("eventCondition", pastEventEventCondition);
+
+        // create the scoring
+        Metadata scoringMetadata = new Metadata("past-event-scoring-test");
+        Scoring scoring = new Scoring(scoringMetadata);
+        List<ScoringElement> scoringElements = new ArrayList<>();
+        ScoringElement scoringElement = new ScoringElement();
+        scoringElement.setCondition(pastEventCondition);
+        scoringElement.setValue(50);
+        scoringElements.add(scoringElement);
+        scoring.setElements(scoringElements);
+        segmentService.setScoringDefinition(scoring);
+        Thread.sleep(5000);
+
+        // Send 2 events that match the scoring plan.
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, timestampEventInRange);
+        testEvent.setPersistent(true);
+        eventService.send(testEvent);
+        refreshPersistence();
+        // 2nd event
+        testEvent = new Event("test-event-type", null, testEvent.getProfile(), null, null, testEvent.getProfile(), timestampEventInRange);
+        eventService.send(testEvent);
+        refreshPersistence();
+
+        // insure the profile is engaged;
+        try {
+            Assert.assertTrue("Profile should have 2 events in the scoring",  (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);

Review comment:
       We have another test that is validating the engaged profiles, I wanted to focus that test to what it is supposed to test. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] jkevan commented on a change in pull request #363: UNOMI-530 : fix maximumEventCount in past event condition

Posted by GitBox <gi...@apache.org>.
jkevan commented on a change in pull request #363:
URL: https://github.com/apache/unomi/pull/363#discussion_r751956251



##########
File path: itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
##########
@@ -358,4 +360,100 @@ public void testScoringPastEventRecalculation() throws Exception {
                 updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test"),
                 1000, 20);
     }
+
+
+    @Test
+    public void testScoringRecalculation() throws Exception {
+        // create Profile
+        Profile profile = new Profile();
+        profile.setItemId("test_profile_id");
+        profileService.save(profile);
+        persistenceService.refreshIndex(Profile.class, null); // wait for profile to be full persisted and index
+
+        Date timestampEventInRange = new SimpleDateFormat("yyyy-MM-dd").parse("2000-10-30");
+        // create the past event condition
+        Condition pastEventCondition = new Condition(definitionsService.getConditionType("pastEventCondition"));
+        pastEventCondition.setParameter("minimumEventCount", 1);
+        pastEventCondition.setParameter("maximumEventCount", 2);
+
+        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");;
+        Condition pastEventEventCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
+        pastEventEventCondition.setParameter("eventTypeId", "test-event-type");
+        pastEventCondition.setParameter("eventCondition", pastEventEventCondition);
+
+        // create the scoring
+        Metadata scoringMetadata = new Metadata("past-event-scoring-test");
+        Scoring scoring = new Scoring(scoringMetadata);
+        List<ScoringElement> scoringElements = new ArrayList<>();
+        ScoringElement scoringElement = new ScoringElement();
+        scoringElement.setCondition(pastEventCondition);
+        scoringElement.setValue(50);
+        scoringElements.add(scoringElement);
+        scoring.setElements(scoringElements);
+        segmentService.setScoringDefinition(scoring);
+        Thread.sleep(5000);
+
+        // Send 2 events that match the scoring plan.
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, timestampEventInRange);
+        testEvent.setPersistent(true);
+        eventService.send(testEvent);
+        refreshPersistence();
+        // 2nd event
+        testEvent = new Event("test-event-type", null, testEvent.getProfile(), null, null, testEvent.getProfile(), timestampEventInRange);
+        eventService.send(testEvent);
+        refreshPersistence();
+
+        // insure the profile is engaged;
+        try {
+            Assert.assertTrue("Profile should have 2 events in the scoring",  (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);

Review comment:
       This is not enough to test that the profile is engaged in the scoring, this is just checking that the auto generated rules are working correctly. But also need to check that the score property is correctly set on the profile.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] dgriffon merged pull request #363: UNOMI-530 : fix maximumEventCount in past event condition

Posted by GitBox <gi...@apache.org>.
dgriffon merged pull request #363:
URL: https://github.com/apache/unomi/pull/363


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] dgriffon commented on a change in pull request #363: UNOMI-530 : fix maximumEventCount in past event condition

Posted by GitBox <gi...@apache.org>.
dgriffon commented on a change in pull request #363:
URL: https://github.com/apache/unomi/pull/363#discussion_r752089853



##########
File path: itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
##########
@@ -358,4 +360,100 @@ public void testScoringPastEventRecalculation() throws Exception {
                 updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test"),
                 1000, 20);
     }
+
+
+    @Test
+    public void testScoringRecalculation() throws Exception {
+        // create Profile
+        Profile profile = new Profile();
+        profile.setItemId("test_profile_id");
+        profileService.save(profile);
+        persistenceService.refreshIndex(Profile.class, null); // wait for profile to be full persisted and index
+
+        Date timestampEventInRange = new SimpleDateFormat("yyyy-MM-dd").parse("2000-10-30");
+        // create the past event condition
+        Condition pastEventCondition = new Condition(definitionsService.getConditionType("pastEventCondition"));
+        pastEventCondition.setParameter("minimumEventCount", 1);
+        pastEventCondition.setParameter("maximumEventCount", 2);
+
+        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");;
+        Condition pastEventEventCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
+        pastEventEventCondition.setParameter("eventTypeId", "test-event-type");
+        pastEventCondition.setParameter("eventCondition", pastEventEventCondition);
+
+        // create the scoring
+        Metadata scoringMetadata = new Metadata("past-event-scoring-test");
+        Scoring scoring = new Scoring(scoringMetadata);
+        List<ScoringElement> scoringElements = new ArrayList<>();
+        ScoringElement scoringElement = new ScoringElement();
+        scoringElement.setCondition(pastEventCondition);
+        scoringElement.setValue(50);
+        scoringElements.add(scoringElement);
+        scoring.setElements(scoringElements);
+        segmentService.setScoringDefinition(scoring);
+        Thread.sleep(5000);
+
+        // Send 2 events that match the scoring plan.
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, timestampEventInRange);
+        testEvent.setPersistent(true);
+        eventService.send(testEvent);
+        refreshPersistence();
+        // 2nd event
+        testEvent = new Event("test-event-type", null, testEvent.getProfile(), null, null, testEvent.getProfile(), timestampEventInRange);
+        eventService.send(testEvent);
+        refreshPersistence();
+
+        // insure the profile is engaged;
+        try {
+            Assert.assertTrue("Profile should have 2 events in the scoring",  (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);

Review comment:
       I updated the test to add the check, thank you for the review




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org