mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
Add scheduler to clean old sessions
This commit is contained in:
parent
00257988ef
commit
18f55d1569
5 changed files with 60 additions and 17 deletions
|
@ -127,3 +127,17 @@ func (s *Storage) RemoveUserSessionByID(userID, sessionID int64) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CleanOldUserSessions removes user sessions older than 30 days.
|
||||
func (s *Storage) CleanOldUserSessions() int64 {
|
||||
query := `DELETE FROM user_sessions
|
||||
WHERE id IN (SELECT id FROM user_sessions WHERE created_at < now() - interval '30 days')`
|
||||
|
||||
result, err := s.db.Exec(query)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
n, _ := result.RowsAffected()
|
||||
return n
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue