5652-ItemTrash #1747
|
@ -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
|
||||
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
jgallego
commented
no comprovem contra =1 perque podria ser que access pose true com a -1
no comprovem contra =1 perque podria ser que access pose true com a -1
`AND a.isActive <> FALSE`
sergiodt
commented
Llevat el procediment Llevat el procediment
|
||||
AND t.created >= (CURRENT_DATE() - INTERVAL 1 YEAR)
|
||||
GROUP BY t.addressFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -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
jgallego
commented
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
jgallego
commented
<> FALSE <> FALSE
sergiodt
commented
Fet Fet
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
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í
}
});
`