This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch fixTimeBasedScoringPlanRecalculation
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to
refs/heads/fixTimeBasedScoringPlanRecalculation by this push:
new 518b1e4 UNOMI-513: stabilize iTests and move painless scripts in
/cxs/painless
518b1e4 is described below
commit 518b1e430618d05d1b3fb6f49833017b52881323
Author: Kevan <[email protected]>
AuthorDate: Fri Oct 1 14:27:54 2021 +0200
UNOMI-513: stabilize iTests and move painless scripts in /cxs/painless
---
.../test/java/org/apache/unomi/itests/SegmentIT.java | 18 ++++++++++--------
.../services/impl/segments/SegmentServiceImpl.java | 4 ++--
.../painless/evaluateScoringPlanElement.painless | 0
.../{ => cxs}/painless/resetScoringPlan.painless | 0
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
index 82046d1..bbb0354 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
@@ -69,11 +69,13 @@ public class SegmentIT extends BaseIT {
@Before
public void setUp() throws InterruptedException {
removeItems(Segment.class);
+ removeItems(Scoring.class);
}
@After
public void tearDown() throws InterruptedException {
removeItems(Segment.class);
+ removeItems(Scoring.class);
removeItems(Profile.class);
removeItems(Event.class);
}
@@ -167,9 +169,9 @@ public class SegmentIT extends BaseIT {
int changes = eventService.send(testEvent);
if ((changes & EventService.PROFILE_UPDATED) ==
EventService.PROFILE_UPDATED) {
profileService.save(profile);
- persistenceService.refreshIndex(Profile.class, new Date());
+ persistenceService.refreshIndex(Profile.class, null);
}
- persistenceService.refreshIndex(Event.class, new Date()); // wait for
event to be fully persisted and indexed
+ persistenceService.refreshIndex(Event.class,
testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
// create the segment
Metadata segmentMetadata = new Metadata("past-event-segment-test");
@@ -215,7 +217,7 @@ public class SegmentIT extends BaseIT {
Event testEvent = new Event("test-event-type", null, profile, null,
null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
testEvent.setPersistent(true);
persistenceService.save(testEvent, null, true);
- persistenceService.refreshIndex(Event.class, new Date()); // wait for
event to be fully persisted and indexed
+ persistenceService.refreshIndex(Event.class,
testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
// insure the profile is not yet engaged since we directly saved the
event in ES
profile = profileService.load("test_profile_id");
@@ -234,7 +236,7 @@ public class SegmentIT extends BaseIT {
localDate = LocalDate.now().minusDays(15);
testEvent = new Event("test-event-type", null, profile, null, null,
profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
persistenceService.save(testEvent);
- persistenceService.refreshIndex(Event.class, new Date()); // wait for
event to be fully persisted and indexed
+ persistenceService.refreshIndex(Event.class,
testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
// now recalculate the past event conditions
segmentService.recalculatePastEventConditions();
@@ -261,9 +263,9 @@ public class SegmentIT extends BaseIT {
int changes = eventService.send(testEvent);
if ((changes & EventService.PROFILE_UPDATED) ==
EventService.PROFILE_UPDATED) {
profileService.save(profile);
- persistenceService.refreshIndex(Profile.class, new Date());
+ persistenceService.refreshIndex(Profile.class, null);
}
- persistenceService.refreshIndex(Event.class, new Date()); // wait for
event to be fully persisted and indexed
+ persistenceService.refreshIndex(Event.class,
testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
// create the past event condition
Condition pastEventCondition = new
Condition(definitionsService.getConditionType("pastEventCondition"));
@@ -325,7 +327,7 @@ public class SegmentIT extends BaseIT {
Event testEvent = new Event("test-event-type", null, profile, null,
null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
testEvent.setPersistent(true);
persistenceService.save(testEvent, null, true);
- persistenceService.refreshIndex(Event.class, new Date()); // wait for
event to be fully persisted and indexed
+ persistenceService.refreshIndex(Event.class,
testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
// insure the profile is not yet engaged since we directly saved the
event in ES
profile = profileService.load("test_profile_id");
@@ -346,7 +348,7 @@ public class SegmentIT extends BaseIT {
localDate = LocalDate.now().minusDays(15);
testEvent = new Event("test-event-type", null, profile, null, null,
profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
persistenceService.save(testEvent);
- persistenceService.refreshIndex(Event.class, new Date()); // wait for
event to be fully persisted and indexed
+ persistenceService.refreshIndex(Event.class,
testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
// now recalculate the past event conditions
segmentService.recalculatePastEventConditions();
diff --git
a/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
b/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
index dec3e24..57dacab 100644
---
a/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
+++
b/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
@@ -963,7 +963,7 @@ public class SegmentServiceImpl extends AbstractServiceImpl
implements SegmentSe
if
(action.getActionTypeId().equals("setEventOccurenceCountAction")) {
Condition pastEventCondition = (Condition)
action.getParameterValues().get("pastEventCondition");
if (pastEventCondition.containsParameter("numberOfDays")) {
-
recalculatePastEventOccurrencesOnProfiles(rule.getCondition(),
pastEventCondition, false, true);
+
recalculatePastEventOccurrencesOnProfiles(rule.getCondition(),
pastEventCondition, true, true);
logger.info("Event occurrence count on profiles
updated for rule: {}", rule.getItemId());
if (rule.getLinkedItems() != null &&
rule.getLinkedItems().size() > 0) {
linkedItems.addAll(rule.getLinkedItems());
@@ -1261,7 +1261,7 @@ public class SegmentServiceImpl extends
AbstractServiceImpl implements SegmentSe
}
private void loadScripts() throws IOException {
- Enumeration<URL> scriptsURL =
bundleContext.getBundle().findEntries("META-INF/painless", "*.painless", true);
+ Enumeration<URL> scriptsURL =
bundleContext.getBundle().findEntries("META-INF/cxs/painless", "*.painless",
true);
if (scriptsURL == null) {
return;
}
diff --git
a/services/src/main/resources/META-INF/painless/evaluateScoringPlanElement.painless
b/services/src/main/resources/META-INF/cxs/painless/evaluateScoringPlanElement.painless
similarity index 100%
rename from
services/src/main/resources/META-INF/painless/evaluateScoringPlanElement.painless
rename to
services/src/main/resources/META-INF/cxs/painless/evaluateScoringPlanElement.painless
diff --git
a/services/src/main/resources/META-INF/painless/resetScoringPlan.painless
b/services/src/main/resources/META-INF/cxs/painless/resetScoringPlan.painless
similarity index 100%
rename from
services/src/main/resources/META-INF/painless/resetScoringPlan.painless
rename to
services/src/main/resources/META-INF/cxs/painless/resetScoringPlan.painless