refactor: refs #7524 wrap it up in a fn
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
1ff1a97f29
commit
e3b51c81f9
|
@ -28,7 +28,7 @@ module.exports = function(Self) {
|
|||
});
|
||||
|
||||
this.beforeRemote('**', async ctx => {
|
||||
if (ctx.method.noLimit || !this.hasFilter(ctx)) return;
|
||||
if (!this.hasFilter(ctx)) return;
|
||||
|
||||
const defaultLimit = this.app.orm.selectLimit;
|
||||
const filter = ctx.args.filter || {limit: defaultLimit};
|
||||
|
@ -40,7 +40,7 @@ module.exports = function(Self) {
|
|||
});
|
||||
|
||||
this.afterRemote('**', async ctx => {
|
||||
if (ctx.method.noLimit || !this.hasFilter(ctx)) return;
|
||||
if (!this.hasFilter(ctx)) return;
|
||||
|
||||
const {result} = ctx;
|
||||
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
|
||||
|
@ -349,8 +349,10 @@ module.exports = function(Self) {
|
|||
},
|
||||
|
||||
hasFilter(ctx) {
|
||||
return ctx.req.method.toUpperCase() === 'GET' &&
|
||||
ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
|
||||
const {method, req} = ctx;
|
||||
if (method.noLimit) return false;
|
||||
return req.method.toUpperCase() === 'GET' &&
|
||||
method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue