Compare commits

..

4 commits
v1.1.0 ... main

5 changed files with 31 additions and 8 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "ff-admin-server",
"version": "1.1.0",
"version": "1.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ff-admin-server",
"version": "1.1.0",
"version": "1.1.1",
"license": "GPL-3.0-only",
"dependencies": {
"cors": "^2.8.5",

View file

@ -1,6 +1,6 @@
{
"name": "ff-admin-server",
"version": "1.1.0",
"version": "1.1.1",
"description": "Feuerwehr/Verein Mitgliederverwaltung Server",
"main": "dist/index.js",
"scripts": {

View file

@ -61,8 +61,13 @@ export async function getAllMembers(req: Request, res: Response): Promise<any> {
let offset = parseInt((req.query.offset as string) ?? "0");
let count = parseInt((req.query.count as string) ?? "25");
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);
let [members, total] = await MemberService.getAll({ offset, count, search, noLimit, ids });
res.json({
members: MemberFactory.mapToBase(members),

View file

@ -141,7 +141,7 @@ export abstract class NewsletterHelper {
}
}
let members = await MemberService.getAll(0, 1000);
let members = await MemberService.getAll({ noLimit: true });
return members[0].filter((m) => queryMemberIds.includes(m.id));
}

View file

@ -8,7 +8,19 @@ export default abstract class MemberService {
* @description get all members
* @returns {Promise<[Array<member>, number]>}
*/
static async getAll(offset: number = 0, count: number = 25, search: string = ""): Promise<[Array<member>, number]> {
static async getAll({
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
.getRepository(member)
.createQueryBuilder("member")
@ -54,9 +66,15 @@ 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
.offset(offset)
.limit(count)
.orderBy("member.lastname")
.addOrderBy("member.firstname")
.addOrderBy("member.nameaffix")