There is total time for session seen in Session viewer, but I could find any parameter what could be used to get the same time in query, what is the best way to get session total time in one query. What is needed is basically session id and time columns where time shows total time in minutes and seconds that session took.
Hi,
Now session total time is not included in session properties so its a bit inconvenient to get it via a TQL query. At this moment you need to create a Groovy Adorner with Adornment key s.a.n:sessionTime and the following code:
import java.text.SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
def beginTime = sdf.parse(session.getValue('beginTime'))
def endTime = sdf.parse(session.getValue('endTime'))
def sessionDuration = (endTime.getTime() - beginTime.getTime())/1000
callback.adorn(session, 's.a.n:sessionTime', sessionDuration)
and then you will have a session property called s.a.n:sessionTime which represents the total time of a session in seconds and it can by queried by TQL like this:
la s.a.n:sessionTime as SessionTotalTime