From 7b2439cb39ed1d4aaffaef12e2f2a30733941d2f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 5 Dec 2024 08:47:28 +0100 Subject: [PATCH 1/2] feat: refs #8248 Added beta in jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19f47c5b0..055cf858f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,8 @@ def RUN_BUILD def BRANCH_ENV = [ test: 'test', - master: 'production' + master: 'production', + beta: 'production' ] node { @@ -18,7 +19,8 @@ node { PROTECTED_BRANCH = [ 'dev', 'test', - 'master' + 'master', + 'beta' ].contains(env.BRANCH_NAME) FROM_GIT = env.JOB_NAME.startsWith('gitea/') From 04a96e87d644c66124436b07c421a089b1df6479 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 8 Dec 2024 07:28:29 +0100 Subject: [PATCH 2/2] refactor: refs #7882 Deleted quadminds files --- .../quadminds-api-config/sendOrders.js | 88 ------------------- back/methods/quadminds-api-config/sendPois.js | 87 ------------------ back/model-config.json | 3 - back/models/quadminds-api-config.js | 4 - back/models/quadminds-api-config.json | 34 ------- .../11378-orangeAsparagus/00-firstScript.sql | 1 + 6 files changed, 1 insertion(+), 216 deletions(-) delete mode 100644 back/methods/quadminds-api-config/sendOrders.js delete mode 100644 back/methods/quadminds-api-config/sendPois.js delete mode 100644 back/models/quadminds-api-config.js delete mode 100644 back/models/quadminds-api-config.json create mode 100644 db/versions/11378-orangeAsparagus/00-firstScript.sql diff --git a/back/methods/quadminds-api-config/sendOrders.js b/back/methods/quadminds-api-config/sendOrders.js deleted file mode 100644 index 760d622b6..000000000 --- a/back/methods/quadminds-api-config/sendOrders.js +++ /dev/null @@ -1,88 +0,0 @@ -const axios = require('axios'); -const UserError = require('vn-loopback/util/user-error'); -const moment = require('moment'); - -module.exports = Self => { - Self.remoteMethod('sendOrders', { - description: 'Sends a set of orders', - accessType: 'WRITE', - accepts: [{ - arg: 'tickets', - type: ['number'], - required: true - } - ], - returns: { - type: 'string', - root: true - }, - http: { - path: `/sendOrders`, - verb: 'POST' - } - }); - Self.sendOrders = async tickets => { - const config = await Self.app.models.QuadmindsApiConfig.findOne(); - if (!config) throw new UserError('Config params not set'); - - if (tickets.length > config.maxObjects) - throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); - - let poisData = []; - let isOk; - for (let offset = 0; !isOk; offset = offset + config.limit) { - const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, { - headers: { - 'Accept': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true; - } - - const poiMap = new Map(poisData.map(poi => [poi.code, poi._id])); - - let orders = await Self.rawSql(` - SELECT a.id poiCode, - t.id code, - t.shipped date, - 'PEDIDO' operation, - t.totalWithVat totalAmount, - t.totalWithoutVat totalAmountWithoutTaxes, - SUM(sv.volume) volume - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN saleVolume sv ON sv.ticketFk = t.id - WHERE t.id IN (?) - GROUP BY t.id - `, [tickets]); - - // Transformo code en string ya que lo obtenermos como integer - orders = orders.map(order => { - return { - ...order, - poiId: poiMap.get(order.poiCode.toString()) || undefined, - code: order.code.toString(), - date: moment(order.date).format('YYYY-MM-DD'), - totalAmount: order.totalAmount || undefined, - totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined, - timeWindow: [{ - from: config.orderTimeFrom, - to: config.orderTimeTo - }], - orderMeasures: [{ - constraintId: 3, // Volumen - value: order.volume - }] - }; - }); - - await axios.post(`${config.url}orders`, orders, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - }; -}; diff --git a/back/methods/quadminds-api-config/sendPois.js b/back/methods/quadminds-api-config/sendPois.js deleted file mode 100644 index cb5eef93e..000000000 --- a/back/methods/quadminds-api-config/sendPois.js +++ /dev/null @@ -1,87 +0,0 @@ -const axios = require('axios'); -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethod('sendPois', { - description: 'Sends a set of pois', - accessType: 'WRITE', - accepts: [{ - arg: 'tickets', - type: ['number'], - required: true - } - ], - returns: { - type: 'string', - root: true - }, - http: { - path: `/sendPois`, - verb: 'POST' - } - }); - Self.sendPois = async tickets => { - const config = await Self.app.models.QuadmindsApiConfig.findOne(); - if (!config) throw new UserError('Config params not set'); - - if (tickets.length > config.maxObjects) - throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); - - let pois = await Self.rawSql(` - WITH deliveryNotes AS ( - SELECT t.id, t.routeFk, tn.description - FROM ticket t - JOIN ticketObservation tn ON tn.ticketFk = t.id - JOIN observationType ot ON ot.id = tn.observationTypeFk - WHERE ot.code = 'delivery' - ) - SELECT a.id code, - c.socialName name, - IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude, - IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude, - a.street, - a.city locality, - p.name state, - co.name country, - CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress, - CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber, - dn.description poiDeliveryComments, - c.email email - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN client c ON c.id = t.clientFk - LEFT JOIN deliveryNotes dn ON dn.id = t.id - WHERE t.id IN (?) - GROUP BY t.id - `, [tickets]); - - // Transformo code en string ya que lo obtenermos como integer - pois = pois.map(poi => { - return { - ...poi, - code: poi.code.toString(), - latitude: poi.latitude || undefined, - longitude: poi.longitude || undefined, - address: { - street: poi.street || undefined, - locality: poi.locality || undefined, - state: poi.state || undefined, - country: poi.country || undefined - }, - poiDeliveryComments: poi.poiDeliveryComments || undefined, - phoneNumber: poi.phoneNumber || undefined, - email: poi.email || undefined - }; - }); - - await axios.post(`${config.url}pois`, pois, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - }; -}; diff --git a/back/model-config.json b/back/model-config.json index 55c34ff64..c1682f29a 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -121,9 +121,6 @@ "Province": { "dataSource": "vn" }, - "QuadmindsApiConfig": { - "dataSource": "vn" - }, "Autonomy": { "dataSource": "vn" }, diff --git a/back/models/quadminds-api-config.js b/back/models/quadminds-api-config.js deleted file mode 100644 index c2773fa0b..000000000 --- a/back/models/quadminds-api-config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = Self => { - require('../methods/quadminds-api-config/sendPois')(Self); - require('../methods/quadminds-api-config/sendOrders')(Self); -}; diff --git a/back/models/quadminds-api-config.json b/back/models/quadminds-api-config.json deleted file mode 100644 index 4001badf3..000000000 --- a/back/models/quadminds-api-config.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "QuadmindsApiConfig", - "base": "VnModel", - "options": { - "mysql": { - "table": "quadmindsApiConfig" - } - }, - "properties": { - "id": { - "type": "number", - "id": true, - "required": true - }, - "url": { - "type": "string" - }, - "key": { - "type": "string" - }, - "maxObjects": { - "type": "number" - }, - "limit": { - "type": "number" - }, - "orderTimeFrom": { - "type": "string" - }, - "orderTimeTo": { - "type": "string" - } - } -} diff --git a/db/versions/11378-orangeAsparagus/00-firstScript.sql b/db/versions/11378-orangeAsparagus/00-firstScript.sql new file mode 100644 index 000000000..a030b7e05 --- /dev/null +++ b/db/versions/11378-orangeAsparagus/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE vn.quadmindsApiConfig;