UNOMI-51 : Scoring modifiers are ignored when the score value is updated

Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/9df17f70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/9df17f70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/9df17f70

Branch: refs/heads/UNOMI-28-ES-2-X-UPGRADE
Commit: 9df17f70988988fc9dc4a1b7cb7c6826e2fe1a54
Parents: 30a51a2
Author: Abdelkader Midani <amid...@jahia.com>
Authored: Wed Aug 10 16:17:04 2016 +0200
Committer: Abdelkader Midani <amid...@jahia.com>
Committed: Fri Aug 12 16:29:32 2016 +0200

----------------------------------------------------------------------
 .../org/apache/unomi/services/services/SegmentServiceImpl.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/9df17f70/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
 
b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
index bd68971..c82aad2 100644
--- 
a/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
+++ 
b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
@@ -851,7 +851,7 @@ public class SegmentServiceImpl implements SegmentService, 
SynchronousBundleList
         scriptParams.put("scoringId", scoring.getItemId());
 
         for (Profile profileToRemove : previousProfiles) {
-            persistenceService.updateWithScript(profileToRemove.getItemId(), 
null, Profile.class, "ctx._source.scores.remove(scoringId)", scriptParams);
+            persistenceService.updateWithScript(profileToRemove.getItemId(), 
null, Profile.class, "if (ctx._source.systemProperties.scoreModifiers == null) 
{ ctx._source.systemProperties.scoreModifiers=[:] } ; if 
(ctx._source.systemProperties.scoreModifiers.containsKey(scoringId)) { 
ctx._source.scores[scoringId] = 
ctx._source.systemProperties.scoreModifiers[scoringId] } else { 
ctx._source.scores.remove(scoringId) }", scriptParams);
         }
         if(scoring.getMetadata().isEnabled()) {
             String script = "if (ctx._source.scores == null) { 
ctx._source.scores=[:] } ; if (ctx._source.scores.containsKey(scoringId)) { 
ctx._source.scores[scoringId] += scoringValue } else { 
ctx._source.scores[scoringId] = scoringValue }";

Reply via email to