[ 
https://issues.apache.org/jira/browse/UNOMI-366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Serge Huber updated UNOMI-366:
------------------------------
    Description: 
Currently interests are incremented in a custom rule such as : 

{code}
{
  "metadata": {
    "id": "_ynqbd6g4t_incrementInterests",
    "name": "Increment profile interests",
    "description": "Increment profile interests when a page is viewed"
  },
  "raiseEventOnlyOnceForSession": true,
  "condition": {
    "parameterValues": {
      "subConditions": [
        {
          "type": "pageViewEventCondition",
          "parameterValues": {
          }
        },
        {
          "type": "eventPropertyCondition",
          "parameterValues": {
            "propertyName": "target.properties.interests",
            "comparisonOperator": "exists"
          }
        }
      ],
      "operator": "and"
    },
    "type": "booleanCondition"
  },
  "actions": [
    {
      "parameterValues": {
        "setPropertyName": "properties.interests",
        "setPropertyValue": "script::r = profile.properties['interests']; 
foreach(interest : event.target.properties['interests'].entrySet()) { if (r == 
null) { r = [interest.key: interest.value] } else if (r[interest.key] != null) 
{ r[interest.key] = r[interest.key] + interest.value } else { r[interest.key] = 
interest.value } } r",
        "storeInSession": false
      },
      "type": "setPropertyAction"
    }
  ]
}
{code}

We should replace this with a new replace the script with a new 
IncrementInterestAction that would do the following:

- (optional) check if topic exists to allow enforcement of only accepting 
existing topics
- increment the interest

Interests inside profiles:

{code}
properties : {
  interests : {
    topic1 : 30.0,
    topic2: 20.0
  }
} 
{code}

Global configuration setting in 
https://github.com/apache/unomi/blob/master/package/src/main/resources/etc/custom.system.properties
 to setup min/max and relative value

{code}
org.apache.unomi.interests.min_value = ${env:UNOMI_INTERESTS_MIN_VALUE:-0.0}
org.apache.unomi.interests.max_value = ${env:UNOMI_INTERESTS_MAX_VALUE:-150.0}
org.apache.unomi.interests.divider_value = 
${env:UNOMI_INTERESTS_DIVIDER_VALUE:-100.0}
{code}

and then in OSGI blueprint files, retrieve the values as such:



So to calculate a cdp_interests we would to :

{code}
CDP_Profile.cdp_interests.topic1.score = min(properties.interests.topic1, 
divider_interest_value) / divider_interest_value
{code}

Incrementing / decrementing interest values should be capped by min_value and 
max_value

{code}
r = profile.properties['interests']; 
foreach(interest : event.target.properties['interests'].entrySet()) { 
  if (r == null) { 
    r = [interest.key: interest.value] 
  } else if (r[interest.key] != null) { 
    r[interest.key] = r[interest.key] + interest.value 
  } else { 
    r[interest.key] = interest.value 
  }
  r[interest.key] = max(min(r[interest.key], max_interest_value), 
min_interest_value)
}
{code}


{code}
{
  "metadata": {
    "id": "incrementInterestAction",
    "name": "incrementInterestAction",
    "description": "",
    "systemTags": [
      "profileTags"
    ],
    "readOnly": true
  },
  "actionExecutor": "incrementInterest",
  "parameters": [
    {
      "id": "topicsToIncrementSource",
      "type": "string",
      "multivalued": false
    }
    {
      "id": "topicsToIncrement",
      "type": "properties",
      "multivalued": false
    }
  ]
}
{code}

{code}
if (topicsToIncrementSource != null) {
  interestMaps = event.getProperty(topicsToIncrementSource);
} else {
  interestMaps = topicsToIncrement;
} 
{code}

  was:
Currently interests are incremented in a custom rule such as : 

{code}
{
  "metadata": {
    "id": "_ynqbd6g4t_incrementInterests",
    "name": "Increment profile interests",
    "description": "Increment profile interests when a page is viewed"
  },
  "raiseEventOnlyOnceForSession": true,
  "condition": {
    "parameterValues": {
      "subConditions": [
        {
          "type": "pageViewEventCondition",
          "parameterValues": {
          }
        },
        {
          "type": "eventPropertyCondition",
          "parameterValues": {
            "propertyName": "target.properties.interests",
            "comparisonOperator": "exists"
          }
        }
      ],
      "operator": "and"
    },
    "type": "booleanCondition"
  },
  "actions": [
    {
      "parameterValues": {
        "setPropertyName": "properties.interests",
        "setPropertyValue": "script::r = profile.properties['interests']; 
foreach(interest : event.target.properties['interests'].entrySet()) { if (r == 
null) { r = [interest.key: interest.value] } else if (r[interest.key] != null) 
{ r[interest.key] = r[interest.key] + interest.value } else { r[interest.key] = 
interest.value } } r",
        "storeInSession": false
      },
      "type": "setPropertyAction"
    }
  ]
}
{code}

We should replace this with a new replace the script with a new 
IncrementInterestAction that would do the following:

- (optional) check if topic exists to allow enforcement of only accepting 
existing topics
- increment the interest

Interests inside profiles:

{code}
properties : {
  interests : {
    topic1 : 30.0,
    topic2: 20.0
  }
} 
{code}

Global configuration setting in 
https://github.com/apache/unomi/blob/master/package/src/main/resources/etc/custom.system.properties
 to setup min/max and relative value

{code}
org.apache.unomi.interests.min_value = ${env:UNOMI_INTERESTS_MIN_VALUE:-0.0}
org.apache.unomi.interests.max_value = ${env:UNOMI_INTERESTS_MAX_VALUE:-150.0}
org.apache.unomi.interests.divider_value = 
${env:UNOMI_INTERESTS_DIVIDER_VALUE:-100.0}
{code}

and then in OSGI blueprint files, retrieve the values as such:



So to calculate a cdp_interests we would to :

{code}
CDP_Profile.cdp_interests.topic1.score = min(properties.interests.topic1, 
divider_interest_value) / divider_interest_value
{code}

Incrementing / decrementing interest values should be capped by min_value and 
max_value

{code}
r = profile.properties['interests']; 
foreach(interest : event.target.properties['interests'].entrySet()) { 
  if (r == null) { 
    r = [interest.key: interest.value] 
  } else if (r[interest.key] != null) { 
    r[interest.key] = r[interest.key] + interest.value 
  } else { 
    r[interest.key] = interest.value 
  }
  r[interest.key] = max(min(r[interest.key], max_interest_value), 
min_interest_value)
}
{code}


> Implement increment interest event type & action
> ------------------------------------------------
>
>                 Key: UNOMI-366
>                 URL: https://issues.apache.org/jira/browse/UNOMI-366
>             Project: Apache Unomi
>          Issue Type: Sub-task
>            Reporter: Serge Huber
>            Assignee: Serge Huber
>            Priority: Major
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Currently interests are incremented in a custom rule such as : 
> {code}
> {
>   "metadata": {
>     "id": "_ynqbd6g4t_incrementInterests",
>     "name": "Increment profile interests",
>     "description": "Increment profile interests when a page is viewed"
>   },
>   "raiseEventOnlyOnceForSession": true,
>   "condition": {
>     "parameterValues": {
>       "subConditions": [
>         {
>           "type": "pageViewEventCondition",
>           "parameterValues": {
>           }
>         },
>         {
>           "type": "eventPropertyCondition",
>           "parameterValues": {
>             "propertyName": "target.properties.interests",
>             "comparisonOperator": "exists"
>           }
>         }
>       ],
>       "operator": "and"
>     },
>     "type": "booleanCondition"
>   },
>   "actions": [
>     {
>       "parameterValues": {
>         "setPropertyName": "properties.interests",
>         "setPropertyValue": "script::r = profile.properties['interests']; 
> foreach(interest : event.target.properties['interests'].entrySet()) { if (r 
> == null) { r = [interest.key: interest.value] } else if (r[interest.key] != 
> null) { r[interest.key] = r[interest.key] + interest.value } else { 
> r[interest.key] = interest.value } } r",
>         "storeInSession": false
>       },
>       "type": "setPropertyAction"
>     }
>   ]
> }
> {code}
> We should replace this with a new replace the script with a new 
> IncrementInterestAction that would do the following:
> - (optional) check if topic exists to allow enforcement of only accepting 
> existing topics
> - increment the interest
> Interests inside profiles:
> {code}
> properties : {
>   interests : {
>     topic1 : 30.0,
>     topic2: 20.0
>   }
> } 
> {code}
> Global configuration setting in 
> https://github.com/apache/unomi/blob/master/package/src/main/resources/etc/custom.system.properties
>  to setup min/max and relative value
> {code}
> org.apache.unomi.interests.min_value = ${env:UNOMI_INTERESTS_MIN_VALUE:-0.0}
> org.apache.unomi.interests.max_value = ${env:UNOMI_INTERESTS_MAX_VALUE:-150.0}
> org.apache.unomi.interests.divider_value = 
> ${env:UNOMI_INTERESTS_DIVIDER_VALUE:-100.0}
> {code}
> and then in OSGI blueprint files, retrieve the values as such:
> So to calculate a cdp_interests we would to :
> {code}
> CDP_Profile.cdp_interests.topic1.score = min(properties.interests.topic1, 
> divider_interest_value) / divider_interest_value
> {code}
> Incrementing / decrementing interest values should be capped by min_value and 
> max_value
> {code}
> r = profile.properties['interests']; 
> foreach(interest : event.target.properties['interests'].entrySet()) { 
>   if (r == null) { 
>     r = [interest.key: interest.value] 
>   } else if (r[interest.key] != null) { 
>     r[interest.key] = r[interest.key] + interest.value 
>   } else { 
>     r[interest.key] = interest.value 
>   }
>   r[interest.key] = max(min(r[interest.key], max_interest_value), 
> min_interest_value)
> }
> {code}
> {code}
> {
>   "metadata": {
>     "id": "incrementInterestAction",
>     "name": "incrementInterestAction",
>     "description": "",
>     "systemTags": [
>       "profileTags"
>     ],
>     "readOnly": true
>   },
>   "actionExecutor": "incrementInterest",
>   "parameters": [
>     {
>       "id": "topicsToIncrementSource",
>       "type": "string",
>       "multivalued": false
>     }
>     {
>       "id": "topicsToIncrement",
>       "type": "properties",
>       "multivalued": false
>     }
>   ]
> }
> {code}
> {code}
> if (topicsToIncrementSource != null) {
>   interestMaps = event.getProperty(topicsToIncrementSource);
> } else {
>   interestMaps = topicsToIncrement;
> } 
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to