You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2021/04/20 12:03:29 UTC

[unomi] branch unomi-1.5.x updated: Add explicit call to update the current profile id of the event (#258)

This is an automated email from the ASF dual-hosted git repository.

shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/unomi-1.5.x by this push:
     new 6373f8d  Add explicit call to update the current profile id of the event (#258)
6373f8d is described below

commit 6373f8d48ef7b2d2d6549f6299dcf7d8f981e2e5
Author: liatiusim <62...@users.noreply.github.com>
AuthorDate: Tue Apr 20 12:17:40 2021 +0300

    Add explicit call to update the current profile id of the event (#258)
    
    (cherry picked from commit 2baf16da141679b3f4fd12307b840982a4740592)
---
 .../baseplugin/actions/MergeProfilesOnPropertyAction.java     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
index cfe04df..f928d75 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
@@ -180,6 +180,13 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor {
                     @Override
                     public boolean execute() {
                         try {
+                            Event currentEvent = event;
+                            // Update current event explicitly, as it might not return from search query if there wasn't a refresh in ES
+                            if (!StringUtils.equals(profileId, masterProfileId)) {
+                                if (currentEvent.isPersistent()) {
+                                    persistenceService.update(currentEvent, currentEvent.getTimeStamp(), Event.class, "profileId", anonymousBrowsing ? null : masterProfileId);
+                                }                            }
+
                             for (Profile profile : profiles) {
                                 String profileId = profile.getItemId();
                                 if (!StringUtils.equals(profileId, masterProfileId)) {
@@ -196,7 +203,9 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor {
 
                                     List<Event> events = persistenceService.query("profileId", profileId, null, Event.class);
                                     for (Event event : events) {
-                                        persistenceService.update(event, event.getTimeStamp(), Event.class, "profileId", anonymousBrowsing ? null : masterProfileId);
+                                        if (!event.getItemId().equals(currentEvent.getItemId())) {
+                                            persistenceService.update(event, event.getTimeStamp(), Event.class, "profileId", anonymousBrowsing ? null : masterProfileId);
+                                        }
                                     }
                                     // we must mark all the profiles that we merged into the master as merged with the master, and they will
                                     // be deleted upon next load