mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-12 22:43:20 -05:00
optimisation: faster update of attempted column
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
parent
4335740bfc
commit
7684b68efd
@ -96,7 +96,7 @@ object Captcha {
|
||||
token match {
|
||||
case Some(value) => {
|
||||
val uuid = getUUID(value)
|
||||
updateAttempted(uuid)
|
||||
updateAttempted(value)
|
||||
Right(Id(uuid))
|
||||
}
|
||||
case None => {
|
||||
@ -121,9 +121,9 @@ object Captcha {
|
||||
}
|
||||
}
|
||||
|
||||
private def updateAttempted(uuid: String): Unit = {
|
||||
private def updateAttempted(token: Int): Unit = {
|
||||
val updateAttemptedPstmt = Statements.tlStmts.get.updateAttemptedPstmt
|
||||
updateAttemptedPstmt.setString(1, uuid)
|
||||
updateAttemptedPstmt.setInt(1, token)
|
||||
updateAttemptedPstmt.executeUpdate()
|
||||
}
|
||||
|
||||
|
@ -64,10 +64,7 @@ class Statements(dbConn: DBConn, maxAttempts: Int) {
|
||||
val updateAttemptedPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
||||
"UPDATE challenge " +
|
||||
"SET attempted = attempted+1 " +
|
||||
"WHERE token = (SELECT m.token " +
|
||||
"FROM mapId m, challenge c " +
|
||||
"WHERE m.token=c.token AND " +
|
||||
"m.uuid = ?)"
|
||||
"WHERE token = ?;"
|
||||
)
|
||||
|
||||
val tokenPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
||||
|
Loading…
Reference in New Issue
Block a user