refs #6531 feat:modify name
gitea/salix/pipeline/pr-test This commit looks good Details

This commit is contained in:
Sergio De la torre 2024-02-19 09:17:57 +01:00
parent 5b541aa804
commit adeca2bb22
2 changed files with 35 additions and 35 deletions

View File

@ -1,25 +1,25 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('myLastModified', { Self.remoteMethodCtx('myLastModified', {
description: 'Get list of last tickets which user has modified', description: 'Get list of last tickets which user has modified',
accessType: 'READ', accessType: 'READ',
returns: { returns: {
type: 'object', type: 'object',
root: true root: true
}, },
http: { http: {
path: `/getLastTicketsByWorker`, path: `/myLastModified`,
verb: 'GET' verb: 'GET'
} }
}); });
Self.getLastTicketsByWorker = async ctx => { Self.myLastModified = async ctx => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const query = const query =
`SELECT ticketFk, MAX(created) created `SELECT ticketFk, MAX(created) created
FROM ticketTracking tt FROM ticketTracking tt
WHERE tt.userFk = ? WHERE tt.userFk = ?
GROUP BY ticketFk GROUP BY ticketFk
LIMIT 5;`; LIMIT 5;`;
return await Self.rawSql(query, [userId]); return await Self.rawSql(query, [userId]);
}; };
}; };

View File

@ -1,10 +1,10 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
describe('getLastTicketsByWorker()', () => { describe('myLastModified()', () => {
it('return list of last tickets which user has modified', async() => { it('return list of last tickets which user has modified', async() => {
let ctx = {req: {accessToken: {userId: 100}}}; let ctx = {req: {accessToken: {userId: 100}}};
let response = await models.Ticket.getLastTicketsByWorker(ctx); let response = await models.Ticket.myLastModified(ctx);
expect(response.length).toBeGreaterThan(0); expect(response.length).toBeGreaterThan(0);
}); });
}); });