laravel-authentication-log
laravel-authentication-log copied to clipboard
Optimize Other Devices Logout Listener
Currently, when logging out of other devices, the listener updates every record for the given user, on a large dataset this can be hundreds of queries. By limiting the scope of the records to only the ones that are not logged out, the number of queries is reduced to a minimum amount.
This can be further optimized by changing the flow to a single update statement. If it is preferred to do it this way I could change the PR.
$user->authentications()
->whereLoginSuccessful(true)
->whereNull('logout_at')
->where('id', '!=', $authenticationLog->id)
->update([
'cleared_by_user' => true,
'logout_at' => now(),
]);
@rappasoft Do you need me to change or add something in order for this to be merged to the main branch.
HI @rappasoft
Is there any update on this PR? need any changes?
Thanks for all the work