Utils class for score management of af:suggestionsSection backed list.
At preset, this provides helper methods to score the suggestions based on frecency.
Frecency is frequency + recency, inspired by Firefox url bar's link scoring logic.
The logic here identifies the selected suggestion item as
a) A new item
b) An item that is previously selected in the same user session
c) An item selected in previous user session
d) An item selected in an earlier user session
Based on this identification, its score is updated by a different margin giving preference
to its frequency and recency.
The decay of score of previously selected suggestion items on selection of a new item is also
based on similar logic.
See updateScores method for the implementation.
Method Summary |
private static Object |
_decrementScores(Object scoreMap, Object sessionTimeStamps)
|
public static Object |
getMinScoredSuggestionKey(Object scoreMap)
Returns the key of the suggestion item with minimum score
|
private static Object |
_getSessionState(Object itemTimeStamp, Object sessionTimeStamps)
Returns if the passed time-stamps is part of current user session, previous user session, or
an older previous session.
|
private static Object |
_incrementScore(Object currentItemScore, Object sessionTimeStamps)
|
protected static Object |
InitClass()
|
public static Object |
sortPerScore(Object suggestionsList, Object scoreMap)
Sorts the suggestions in the suggestionsList array based on the scores present in scoreMap
|
public static Object |
updateScores(String storageKey, Object preferredSuggestions, Number|String currentValue)
Updates the scores on selection of new item
|
private static Object |
_updateSessionState(String storageKey, Object preferredSuggestions)
Popuplates the sessionStorage with
a) time-stamp of previous session when the current localStorage item was accessed
b) current time
and also caches the current time on the localStorage (via preferredSuggestions object) which
will be helpful in determining the previous session timestamp in the next user session
A combination of these two time-stamps will be helpful to determine if the suggestion item
was earlier selected within the same user session, previous user session, or in an earlier
user session.
|