Jerome Blanchard created UNOMI-922:
--------------------------------------

             Summary: Incoherency between value for nbOfVisits in Profile and 
number of Sessions
                 Key: UNOMI-922
                 URL: https://issues.apache.org/jira/browse/UNOMI-922
             Project: Apache Unomi
          Issue Type: Bug
            Reporter: Jerome Blanchard


When a session is created or merged for a profile, a rule increment nbOfVisits 
of that profile.
Thus, the number of sessions associated to a profile should be equal to the 
nbOfVisits of that profile which the case until old sessions are purged. 

When ProfileService.purgeSessionItems() is called, Sessions older that a 
certain age are removed but Profile.nbOfVisists is not decremented accordingly. 
Thus, with time, values are incoherent between a live calculation of profile's 
sessions and the already calculated nbOfVisits.

The goal of that ticket is to keep the concept of TotalNbOfVisits (including 
visits calculated over removed sessions) and a NbOfVisits (correlated with the 
Session max TTL) decremented when some sessions are purged.

The implementation will consist of : 
- add a migration step to copy existing value of  nbOfVisits into a new 
totalNbOfVisits property. 
- for each profile, update the existing nbOfVisits to equals the number of 
existing sessions related to that profileId.
- update the rule for events SessionMerged and SessionCreated to increment both 
nbOfVisits and totalNbOfVisits 
- update the action of purgeSessionItems() to aggregate session's to purge by 
profile id and, after the purge, to iterate over that aggregation to decrement 
each impacted profile's nbOfVisits accordingly. 

An alternative could be to migrate to a time based  object for nbOfVisits : 
nbOfVisits : {
"1d": 2,
"1w": 8,
"1m": 14,
"6m": 15,
"1y": 15,
"2y": 15,
"total": 15
}

The incoherency is mainly visible between a screen that display profiles in 
table (with nbOfVisit value) and kibana dashboard that calculate that number of 
visits by querying sessions.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to