Skip to content
Snippets Groups Projects
Commit 932aaa8f72bf authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Use SQL query to remove old login attempt

This is more efficient if there are a huge number of old login attempt because
it avoid to fetch the ids and to have loop over them to delete.

issue5377
review24901002
parent a6624f31ff20
No related merge requests found
......@@ -563,9 +563,10 @@
@classmethod
@_login_size
def add(cls, login):
cls.delete(cls.search([
('create_date', '<', cls.delay()),
]))
cursor = Transaction().connection.cursor()
table = cls.__table__()
cursor.execute(*table.delete(where=table.create_date < cls.delay()))
cls.create([{'login': login}])
@classmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment