randomSelect的一个小bug
This commit is contained in:
parent
b37e05ac39
commit
002ab66882
|
|
@ -83,10 +83,10 @@ async function select(params, context) {
|
|||
id: 1,
|
||||
},
|
||||
});
|
||||
const ids = await context.select(entity, idSelection, option || {});
|
||||
const possibility = count / ids.length;
|
||||
let reduced = ids.length - count;
|
||||
const ids2 = ids.filter((id) => {
|
||||
const idResults = await context.select(entity, idSelection, option || {});
|
||||
const possibility = count / idResults.length;
|
||||
let reduced = idResults.length - count;
|
||||
const ids2 = idResults.map(ele => ele.id).filter((id) => {
|
||||
const rand = Math.random();
|
||||
if (rand > possibility && reduced) {
|
||||
reduced--;
|
||||
|
|
|
|||
|
|
@ -138,15 +138,15 @@ export async function select<
|
|||
},
|
||||
});
|
||||
|
||||
const ids = await context.select(
|
||||
const idResults = await context.select(
|
||||
entity,
|
||||
idSelection,
|
||||
option || {}
|
||||
);
|
||||
|
||||
const possibility = count! / ids.length;
|
||||
let reduced = ids.length - count!;
|
||||
const ids2 = ids.filter(
|
||||
const possibility = count! / idResults.length;
|
||||
let reduced = idResults.length - count!;
|
||||
const ids2 = idResults.map(ele => ele.id).filter(
|
||||
(id) => {
|
||||
const rand = Math.random();
|
||||
if (rand > possibility && reduced) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue