Access Log with Login, Logout, and Duration

Contains tips for configurators working with Aware IM
Post Reply
kklosson
Posts: 1617
Joined: Sun Nov 23, 2008 3:19 pm
Location: Virginia

Access Log with Login, Logout, and Duration

Post by kklosson »

I'm interested in creating an access log that shows the login, the logout, and the duration of each session. Login, I got. But this requires that at logout, I find the latest login record for the current user and then update the logout date/time and calculate the duration.

I've not been able to really figure out how to fetch a record and update values in a process or rule. In my case, I need to FIND the log record where it belongs to the current user AND is has the latest login timestamp.

Any quick thoughts/guidance?
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Something like will find the latest entry in a log:

FIND UserLog WHERE UserLog.LoginName=LoggedInRegularUser.LoginName ORDER BY UserLog.LogTime DESC TAKE BEST 1



If it helps at all, here is a rule that I sometimes as a Logout Notification in the section 'When Logout Notification is Received"

LoggedInRegularUser.LastLogoutTime=CURRENT_TIMESTAMP
LoggedInRegularUser.LastLogoutTimeout=LogoutNotification.IsTimeout
LoggedInRegularUser.LastLoginDuration=LoggedInRegularUser.LastLogoutTime-LoggedInRegularUser.LastLoginTime

One other idea would be to collect the duration info in the RegularUser instance with the above rule, then add a RegularUser rule to CREATE an appropriate log record using the duration info that is calculated above.

Tom
kklosson
Posts: 1617
Joined: Sun Nov 23, 2008 3:19 pm
Location: Virginia

Post by kklosson »

Here's something that doesn't work:

FIND AccessLog WHERE Candidate=LoggedInCandidate ORDER BY AccessLog.LogInDateTime DESC TAKE BEST 1

AccessLog.LogOutDateTime=CURRENT_TIMESTAMP

UPDATE AccessLog

Any suggestions?
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Are you using the context helper? It does not seem like it with some of the rule issues that you have had.

FIND AccessLog WHERE AccessLog.Candidate=LoggedInCandidate... ????

Do you need the UPDATE action? Not sure in your scenario.

Tom
kklosson
Posts: 1617
Joined: Sun Nov 23, 2008 3:19 pm
Location: Virginia

Post by kklosson »

Thanks, I have it now. Easier than I thought plus I didn't have the rule in the right place under the notification.

Again, thanks for the help.
Post Reply