5652-ItemTrash #1747

Merged
sergiodt merged 12 commits from 5652-ItemTrash into dev 2023-09-18 05:44:32 +00:00
3 changed files with 4 additions and 5 deletions
Showing only changes of commit 5f5a0645be - Show all commits

View File

@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_getLosesLastYear`()
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_getLoses`()
sergiodt marked this conversation as resolved Outdated

intentar no crear proc, chatGPT me l'ha pasat a loopback

`const Ticket = app.models.Ticket; // Asegúrate de reemplazar 'app' con tu instancia de LoopBack

Ticket.find({
include: [
{
relation: 'address',
scope: {
where: {
isactive: 1,
},
include: {
relation: 'client',
scope: {
where: {
typeFk: 'loses',
},
},
},
},
},
],
fields: ['addressFk'], // Puedes seleccionar los campos que necesites aquí
group: 'addressFk',
}, (err, results) => {
if (err) {
console.error(err);
// Manejar el error aquí
} else {
console.log(results);
// Procesar los resultados aquí
}
});
`

intentar no crear proc, chatGPT me l'ha pasat a loopback `const Ticket = app.models.Ticket; // Asegúrate de reemplazar 'app' con tu instancia de LoopBack Ticket.find({ include: [ { relation: 'address', scope: { where: { isactive: 1, }, include: { relation: 'client', scope: { where: { typeFk: 'loses', }, }, }, }, }, ], fields: ['addressFk'], // Puedes seleccionar los campos que necesites aquí group: 'addressFk', }, (err, results) => { if (err) { console.error(err); // Manejar el error aquí } else { console.log(results); // Procesar los resultados aquí } }); `
BEGIN
SELECT t.addressFk , a.nickname, c.name
FROM ticket t
@ -8,7 +8,6 @@ BEGIN
JOIN client c ON a.clientFk = c.id
WHERE c.typeFk = 'loses'
AND a.isactive = 1
sergiodt marked this conversation as resolved Outdated

no comprovem contra =1 perque podria ser que access pose true com a -1

AND a.isActive <> FALSE

no comprovem contra =1 perque podria ser que access pose true com a -1 `AND a.isActive <> FALSE`

Llevat el procediment

Llevat el procediment
AND t.created >= (CURRENT_DATE() - INTERVAL 1 YEAR)
GROUP BY t.addressFk;
END$$
DELIMITER ;

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethod('getAddress', {
description: 'Get all activated address last year ',
description: 'Get all activated address client active',
accessType: 'READ',
accepts: [],
returns: {
@ -14,7 +14,7 @@ module.exports = Self => {
});
Self.getAddress = async() => {
const query = `CALL vn.address_getLosesLastYear()`;
const query = `CALL vn.address_getLoses()`;
sergiodt marked this conversation as resolved Outdated

aci el codi de loopback que t'he posat abans

aci el codi de loopback que t'he posat abans
const [result] = await Self.rawSql(query);
return result;
sergiodt marked this conversation as resolved Outdated

<> FALSE

<> FALSE

Fet

Fet
};

View File

@ -1,7 +1,7 @@
const {models} = require('vn-loopback/server/server');
describe('getAddress()', () => {
it('return list of address last year', async() => {
fit('return list of address last year', async() => {
let response = await models.Address.getAddress();
expect(response.length).toBeGreaterThan(0);