mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-13 15:03: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 {
|
token match {
|
||||||
case Some(value) => {
|
case Some(value) => {
|
||||||
val uuid = getUUID(value)
|
val uuid = getUUID(value)
|
||||||
updateAttempted(uuid)
|
updateAttempted(value)
|
||||||
Right(Id(uuid))
|
Right(Id(uuid))
|
||||||
}
|
}
|
||||||
case None => {
|
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
|
val updateAttemptedPstmt = Statements.tlStmts.get.updateAttemptedPstmt
|
||||||
updateAttemptedPstmt.setString(1, uuid)
|
updateAttemptedPstmt.setInt(1, token)
|
||||||
updateAttemptedPstmt.executeUpdate()
|
updateAttemptedPstmt.executeUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +64,7 @@ class Statements(dbConn: DBConn, maxAttempts: Int) {
|
|||||||
val updateAttemptedPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
val updateAttemptedPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
||||||
"UPDATE challenge " +
|
"UPDATE challenge " +
|
||||||
"SET attempted = attempted+1 " +
|
"SET attempted = attempted+1 " +
|
||||||
"WHERE token = (SELECT m.token " +
|
"WHERE token = ?;"
|
||||||
"FROM mapId m, challenge c " +
|
|
||||||
"WHERE m.token=c.token AND " +
|
|
||||||
"m.uuid = ?)"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val tokenPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
val tokenPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
||||||
|
Loading…
Reference in New Issue
Block a user