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 2020/11/09 14:55:09 UTC

[GitHub] [unomi] sergehuber commented on a change in pull request #201: UNOMI-366: Implement increment interest event type & action

sergehuber commented on a change in pull request #201:
URL: https://github.com/apache/unomi/pull/201#discussion_r519873896



##########
File path: plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/IncrementInterestAction.java
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.unomi.plugins.baseplugin.actions;
+
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.Profile;
+import org.apache.unomi.api.actions.Action;
+import org.apache.unomi.api.actions.ActionExecutor;
+import org.apache.unomi.api.services.EventService;
+import org.apache.unomi.api.services.TopicService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class IncrementInterestAction implements ActionExecutor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(IncrementInterestAction.class.getName());
+
+    private TopicService topicService;
+
+    private EventService eventService;
+
+    private Double interestsMinValue;
+
+    private Double interestsMaxValue;
+
+    private Double interestsDividerValue;
+
+    @Override
+    public int execute(final Action action, final Event event) {
+        final Map<String, Double> interestsAsMap = (Map<String, Double>) event.getProperty("interests");

Review comment:
       I'm sorry I wasn't clear enough. What I meant is that until now when a page view event was sent, it would also contain a list of topics that are metadata on the page and that should be used to increment the interests on the profile. Here's an example of such an event:
   
   unomiTracker.initialize({
              ​scope: 'myScope',
              ​url: 'http://unomi:8181', // we use an empty URL to make it relative to this page.
              ​initialPageProperties: {
                  ​path: path,
                  ​pageInfo: {
                      ​destinationURL: location.href,
                      ​tags: ["tag1", "tag2", "tag3"],
                      ​categories: ["category1", "category2", "category3"]
                  ​},
                  ​interests: {
                      ​"interest1": 1,
                      ​"interest2": 2,
                      ​"interest3": 3
                  ​}
              ​}
          ​})
   
   I was hoping we could modify the action to also be able to extract the interests from this type of event, which is why I was suggesting to have an action parameter like "eventInterestProperty" : "target.properties.interests"
   




----------------------------------------------------------------
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.

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