From 2e90bf1ba0c70b1235e3f227e8a5bb2057859520 Mon Sep 17 00:00:00 2001 From: Tomasz Rojek Date: Mon, 3 Jun 2024 11:54:02 +0200 Subject: [PATCH] feat: set next run --- CHANGELOG.md | 3 +++ package.json | 2 +- src/db/orders-dao.ts | 8 ++++++++ src/orders-local-queue-service.ts | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a36a9..0a5964f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index a480d81..22bad7d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/db/orders-dao.ts b/src/db/orders-dao.ts index b8327c7..5f9f3ee 100644 --- a/src/db/orders-dao.ts +++ b/src/db/orders-dao.ts @@ -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( @@ -192,4 +199,5 @@ module.exports = { getOrdersInStage, getStats, isOrderWithCheckSeqInDb, + setNextRunInSeconds, }; diff --git a/src/orders-local-queue-service.ts b/src/orders-local-queue-service.ts index 65986af..4cd8fbb 100644 --- a/src/orders-local-queue-service.ts +++ b/src/orders-local-queue-service.ts @@ -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); } @@ -157,6 +161,7 @@ export function getOrdersQueue(dbFileName?: string) { addOrderToProcessingQueue, pullOrdersAndAddToProcessingQueue, setOrderStage, + setNextRunInSeconds, updateOrderBody, updateOrderExtraData, getOrder,