apply limit to resulting array
All checks were successful
backend-action / build-image (push) Successful in 6m21s
All checks were successful
backend-action / build-image (push) Successful in 6m21s
This commit is contained in:
@@ -177,7 +177,7 @@ async function getAllUser(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const topThree = await db.query.user.findMany({
|
const topTen = await db.query.user.findMany({
|
||||||
with: {
|
with: {
|
||||||
group: true,
|
group: true,
|
||||||
opinions: {
|
opinions: {
|
||||||
@@ -187,7 +187,7 @@ async function getAllUser(
|
|||||||
with: { province: true },
|
with: { province: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
limit: 3,
|
limit: 10,
|
||||||
orderBy: user.rank,
|
orderBy: user.rank,
|
||||||
where: (user, { eq, and }) => {
|
where: (user, { eq, and }) => {
|
||||||
const conditions: SQL[] = [];
|
const conditions: SQL[] = [];
|
||||||
@@ -247,17 +247,19 @@ async function getAllUser(
|
|||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
resultUser = [
|
resultUser = [
|
||||||
...topThree,
|
...topTen,
|
||||||
...users.filter((u) => topThree.filter((v) => v.id == u.id).length == 0),
|
...users.filter((u) => topTen.filter((v) => v.id == u.id).length == 0),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultUser.map((u) => ({
|
return resultUser
|
||||||
...u,
|
.map((u) => ({
|
||||||
phone: hidePhone(u.phone),
|
...u,
|
||||||
verified: true,
|
phone: hidePhone(u.phone),
|
||||||
image: u.image ? `${Config.minioPublicBucketEndpoint}${u.image}` : null,
|
verified: true,
|
||||||
}));
|
image: u.image ? `${Config.minioPublicBucketEndpoint}${u.image}` : null,
|
||||||
|
}))
|
||||||
|
.slice(0, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUser(userId: number, showPhone: boolean) {
|
async function getUser(userId: number, showPhone: boolean) {
|
||||||
|
|||||||
Reference in New Issue
Block a user