simplify logic for background task
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
parent
6758ec3acf
commit
497b88f0d3
|
@ -18,13 +18,17 @@ class BackgroundTask(config: Config, captcha: Captcha) {
|
||||||
val challengeGCPstmt = Statements.tlStmts.get.challengeGCPstmt
|
val challengeGCPstmt = Statements.tlStmts.get.challengeGCPstmt
|
||||||
challengeGCPstmt.executeUpdate()
|
challengeGCPstmt.executeUpdate()
|
||||||
|
|
||||||
val imageNum = Statements.tlStmts.get.getCountChallengeTable.executeQuery()
|
val imageNumResult = Statements.tlStmts.get.getCountChallengeTable.executeQuery()
|
||||||
var throttleIn = (config.throttle * 1.1).toInt
|
val imageNum = if (imageNumResult.next()) {
|
||||||
if (imageNum.next())
|
imageNumResult.getInt("total")
|
||||||
throttleIn = (throttleIn - imageNum.getInt("total"))
|
} else {
|
||||||
while (0 < throttleIn) {
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
val throttle = (config.throttle * 1.1).toInt - imageNum
|
||||||
|
|
||||||
|
for (i <- 0 until throttle) {
|
||||||
captcha.generateChallenge(getRandomParam())
|
captcha.generateChallenge(getRandomParam())
|
||||||
throttleIn -= 1
|
|
||||||
}
|
}
|
||||||
} catch { case exception: Exception => println(exception) }
|
} catch { case exception: Exception => println(exception) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue