Compare commits
No commits in common. "0bbe22e9ae2bf841f52491b9c95c1026b8c4a9a1" and "8b59f3b7a8c9b5b0993dc4003eaf704fdfc68462" have entirely different histories.
0bbe22e9ae
...
8b59f3b7a8
3 changed files with 5 additions and 28 deletions
|
@ -61,13 +61,8 @@ export async function getAllMembers(req: Request, res: Response): Promise<any> {
|
||||||
let offset = parseInt((req.query.offset as string) ?? "0");
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||||
let count = parseInt((req.query.count as string) ?? "25");
|
let count = parseInt((req.query.count as string) ?? "25");
|
||||||
let search = (req.query.search as string) ?? "";
|
let search = (req.query.search as string) ?? "";
|
||||||
let noLimit = req.query.noLimit === "true";
|
|
||||||
let ids = ((req.query.ids ?? "") as string)
|
|
||||||
.split(",")
|
|
||||||
.filter((i) => i)
|
|
||||||
.map((i) => parseInt(i));
|
|
||||||
|
|
||||||
let [members, total] = await MemberService.getAll({ offset, count, search, noLimit, ids });
|
let [members, total] = await MemberService.getAll(offset, count, search);
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
members: MemberFactory.mapToBase(members),
|
members: MemberFactory.mapToBase(members),
|
||||||
|
|
|
@ -141,7 +141,7 @@ export abstract class NewsletterHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let members = await MemberService.getAll({ noLimit: true });
|
let members = await MemberService.getAll(0, 1000);
|
||||||
|
|
||||||
return members[0].filter((m) => queryMemberIds.includes(m.id));
|
return members[0].filter((m) => queryMemberIds.includes(m.id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,7 @@ export default abstract class MemberService {
|
||||||
* @description get all members
|
* @description get all members
|
||||||
* @returns {Promise<[Array<member>, number]>}
|
* @returns {Promise<[Array<member>, number]>}
|
||||||
*/
|
*/
|
||||||
static async getAll({
|
static async getAll(offset: number = 0, count: number = 25, search: string = ""): Promise<[Array<member>, number]> {
|
||||||
offset = 0,
|
|
||||||
count = 25,
|
|
||||||
search = "",
|
|
||||||
noLimit = false,
|
|
||||||
ids = [],
|
|
||||||
}: {
|
|
||||||
offset?: number;
|
|
||||||
count?: number;
|
|
||||||
search?: string;
|
|
||||||
noLimit?: boolean;
|
|
||||||
ids?: Array<number>;
|
|
||||||
}): Promise<[Array<member>, number]> {
|
|
||||||
let query = dataSource
|
let query = dataSource
|
||||||
.getRepository(member)
|
.getRepository(member)
|
||||||
.createQueryBuilder("member")
|
.createQueryBuilder("member")
|
||||||
|
@ -66,15 +54,9 @@ export default abstract class MemberService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ids.length != 0) {
|
|
||||||
query = query.where({ id: ids });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!noLimit) {
|
|
||||||
query = query.offset(offset).limit(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await query
|
return await query
|
||||||
|
.offset(offset)
|
||||||
|
.limit(count)
|
||||||
.orderBy("member.lastname")
|
.orderBy("member.lastname")
|
||||||
.addOrderBy("member.firstname")
|
.addOrderBy("member.firstname")
|
||||||
.addOrderBy("member.nameaffix")
|
.addOrderBy("member.nameaffix")
|
||||||
|
|
Loading…
Reference in a new issue