fix(medusa-plugin-brightpearl): more gentle inventory syncs

This commit is contained in:
Sebastian Rindom
2020-08-28 11:19:20 +02:00
parent 70e8fcde41
commit e25478034b
4 changed files with 86 additions and 38 deletions
@@ -18,38 +18,39 @@ var inventorySync = /*#__PURE__*/function () {
case 0:
brightpearlService = container.resolve("brightpearlService");
eventBus = container.resolve("eventBusService");
_context.prev = 2;
_context.next = 5;
console.log("hi inventory");
_context.prev = 3;
_context.next = 6;
return brightpearlService.getClient();
case 5:
case 6:
client = _context.sent;
pattern = "43 4,10,14,20 * * *"; // nice for tests "*/10 * * * * *"
eventBus.createCronJob("inventory-sync", {}, pattern, brightpearlService.syncInventory());
_context.next = 15;
_context.next = 16;
break;
case 10:
_context.prev = 10;
_context.t0 = _context["catch"](2);
case 11:
_context.prev = 11;
_context.t0 = _context["catch"](3);
if (!(_context.t0.name === "not_allowed")) {
_context.next = 14;
_context.next = 15;
break;
}
return _context.abrupt("return");
case 14:
case 15:
throw _context.t0;
case 15:
case 16:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 10]]);
}, _callee, null, [[3, 11]]);
}));
return function inventorySync(_x) {