Comparing version 0.2.3 to 0.2.4
@@ -86,8 +86,8 @@ /// <reference path="type_declarations/index.d.ts" /> | ||
function fetchNext(public_api, callback) { | ||
// find which program is the oldest | ||
exports.db.SelectOne('program_last_fetched') | ||
.orderBy("COALESCE(last_fetched, '1970-01-01')") | ||
.execute(function (error, program) { | ||
// find which program is the oldest and update it in one go. | ||
// this is not entirely race-condition free, but pretty close! | ||
exports.db.query("UPDATE program AS t1 SET last_fetched = NOW()\n FROM (SELECT * FROM program ORDER BY last_fetched LIMIT 1) AS t2\n WHERE t1.id = t2.id\n RETURNING *", [], function (error, programs) { | ||
if (error) | ||
return callback(error); | ||
var program = programs[0]; | ||
logger.debug("[" + new Date().toISOString() + "] fetchNext: program.id=" + program.id); | ||
@@ -94,0 +94,0 @@ public_api.listProgramKiosks(program.bcycle_program_id, function (error, public_api_kiosks) { |
@@ -128,8 +128,12 @@ /// <reference path="type_declarations/index.d.ts" /> | ||
export function fetchNext(public_api: PublicAPI, callback: (error?: Error) => void) { | ||
// find which program is the oldest | ||
db.SelectOne('program_last_fetched') | ||
.orderBy("COALESCE(last_fetched, '1970-01-01')") | ||
.execute((error: Error, program: Program) => { | ||
// find which program is the oldest and update it in one go. | ||
// this is not entirely race-condition free, but pretty close! | ||
db.query(`UPDATE program AS t1 SET last_fetched = NOW() | ||
FROM (SELECT * FROM program ORDER BY last_fetched LIMIT 1) AS t2 | ||
WHERE t1.id = t2.id | ||
RETURNING *`, [], (error: Error, programs: Program[]) => { | ||
if (error) return callback(error); | ||
var program = programs[0]; | ||
logger.debug(`[${new Date().toISOString()}] fetchNext: program.id=${program.id}`); | ||
@@ -136,0 +140,0 @@ |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/chbrown/bcycle", | ||
@@ -10,0 +10,0 @@ "repository": "git://github.com/chbrown/bcycle.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131318
19
2900