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: {
|
||||
group: true,
|
||||
opinions: {
|
||||
@@ -187,7 +187,7 @@ async function getAllUser(
|
||||
with: { province: true },
|
||||
},
|
||||
},
|
||||
limit: 3,
|
||||
limit: 10,
|
||||
orderBy: user.rank,
|
||||
where: (user, { eq, and }) => {
|
||||
const conditions: SQL[] = [];
|
||||
@@ -247,17 +247,19 @@ async function getAllUser(
|
||||
];
|
||||
} else {
|
||||
resultUser = [
|
||||
...topThree,
|
||||
...users.filter((u) => topThree.filter((v) => v.id == u.id).length == 0),
|
||||
...topTen,
|
||||
...users.filter((u) => topTen.filter((v) => v.id == u.id).length == 0),
|
||||
];
|
||||
}
|
||||
|
||||
return resultUser.map((u) => ({
|
||||
return resultUser
|
||||
.map((u) => ({
|
||||
...u,
|
||||
phone: hidePhone(u.phone),
|
||||
verified: true,
|
||||
image: u.image ? `${Config.minioPublicBucketEndpoint}${u.image}` : null,
|
||||
}));
|
||||
}))
|
||||
.slice(0, limit);
|
||||
}
|
||||
|
||||
async function getUser(userId: number, showPhone: boolean) {
|
||||
|
||||
Reference in New Issue
Block a user