Skip to content

Commit

Permalink
feat: set next run
Browse files Browse the repository at this point in the history
  • Loading branch information
tomek3e committed Jun 3, 2024
1 parent cbcd9b4 commit 2e90bf1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.0] - 2024-06-03
- Feature: set next run

## [2.2.0] - 2024-02-23
- Feature: order append lines

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orderingstack/pos-integrator-core",
"version": "2.2.0",
"version": "2.3.0",
"description": "Ordering Stack POS integrator core - library for easy developing POS integrations with Ordering Stack platform.",
"scripts": {
"test": "jest",
Expand Down
8 changes: 8 additions & 0 deletions src/db/orders-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ function setOrderStage(db: Database, orderId: string, stage: string) {
stmt.run([stage, orderId]);
}

function setNextRunInSeconds(db: Database, orderId: string, seconds: number) {
const stmt = db.prepare(
"UPDATE OSL_ORDER SET nextStageRunAt=DateTime('now', '+? seconds') WHERE id=?",
);
stmt.run([seconds, orderId]);
}

// TODO: do not removew if order is not processed and closed - attrs: closed, completed, status, processed
function removeOlderThan(db: Database, days: number) {
const stmt = db.prepare(
Expand Down Expand Up @@ -192,4 +199,5 @@ module.exports = {
getOrdersInStage,
getStats,
isOrderWithCheckSeqInDb,
setNextRunInSeconds,
};
5 changes: 5 additions & 0 deletions src/orders-local-queue-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ function setOrderStage(orderId: string, stage: string) {
orderDao.setOrderStage(db, orderId, stage);
}

function setNextRunInSeconds(orderId: string, seconds: number) {
orderDao.setNextRunInSeconds(db, orderId, seconds);
}

function updateOrderBody(orderRec: IOrderRecord) {
orderDao.updateOrderBody(db, orderRec);
}
Expand Down Expand Up @@ -157,6 +161,7 @@ export function getOrdersQueue(dbFileName?: string) {
addOrderToProcessingQueue,
pullOrdersAndAddToProcessingQueue,
setOrderStage,
setNextRunInSeconds,
updateOrderBody,
updateOrderExtraData,
getOrder,
Expand Down

0 comments on commit 2e90bf1

Please sign in to comment.