Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2017 07:03
Show Gist options
  • Save anonymous/f34c2dcb691f059638fbd1cf5ab699e5 to your computer and use it in GitHub Desktop.
Save anonymous/f34c2dcb691f059638fbd1cf5ab699e5 to your computer and use it in GitHub Desktop.
import db_mysql, os, strutils, times, math
let db = open("localhost", "something", "pass", "something")
while true:
for job in db.fastRows(sql"SELECT * FROM `jobs` WHERE `progress` < `clicks`"):
var jobId = job[0].parseInt
var user_id = job[1].parseInt
var timeNow = int(round(epochTime()))
var dripSeconds = drip * 60 * 60
var dripRate = drip / dripSeconds
if dripRate >= 1 or drip == 0:
var jobHold = db.exec(sql"UPDATE `jobs` SET `progress` = `progress` + 1 WHERE `ID` = ?", jobId)
#if jobHold:
# echo "got here"
#else:
# echo "problem"
sleep(1000)
db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment