Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit bad604b

Browse files
committed
fix(server): getAccountUsers user count
1 parent 635f588 commit bad604b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/server/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,16 @@ onClientCallback(
248248
queryParams.push(wildcard);
249249
}
250250

251+
const usersCount = await oxmysql.prepare<number>(
252+
`SELECT COUNT(*) FROM \`accounts_access\` aa LEFT JOIN characters c ON c.charId = aa.charId WHERE accountId = ? ${searchStr}`,
253+
queryParams
254+
);
255+
251256
queryParams.push(page * 7);
252257

253-
const users = await oxmysql.rawExecute<AccessTableData['users']>(
254-
`
258+
const users = usersCount
259+
? await oxmysql.rawExecute<AccessTableData['users']>(
260+
`
255261
SELECT c.stateId, a.role, c.fullName AS \`name\` FROM \`accounts_access\` a
256262
LEFT JOIN \`characters\` c ON c.charId = a.charId
257263
WHERE a.accountId = ?
@@ -260,18 +266,12 @@ onClientCallback(
260266
LIMIT 7
261267
OFFSET ?
262268
`,
263-
queryParams
264-
);
265-
266-
console.log(JSON.stringify(users, null, 2));
267-
268-
const usersCount = await oxmysql.prepare<number>(
269-
'SELECT COUNT(*) FROM `accounts_access` aa LEFT JOIN characters c ON c.charId = aa.charId WHERE accountId = ? AND MATCH(c.fullName) AGAINST (? IN BOOLEAN MODE)',
270-
[accountId, wildcard]
271-
);
269+
queryParams
270+
)
271+
: [];
272272

273273
return {
274-
numberOfPages: Math.ceil(usersCount / 7),
274+
numberOfPages: Math.ceil(usersCount / 7) || 1,
275275
users,
276276
};
277277
}

0 commit comments

Comments
 (0)