Einbau Validation finished

This commit is contained in:
2024-08-03 12:16:04 +02:00
parent f58448679d
commit 4c1b1fbc87
19 changed files with 421 additions and 338 deletions

View File

@@ -21,18 +21,7 @@ export class UserService {
private fileService: FileService,
private geoService: GeoService,
) {}
// private getConditions(criteria: UserListingCriteria): any[] {
// const conditions = [];
// if (criteria.states?.length > 0) {
// criteria.states.forEach(state => {
// conditions.push(sql`${schema.users.areasServed} @> ${JSON.stringify([{ state: state }])}`);
// });
// }
// if (criteria.firstname || criteria.lastname) {
// conditions.push(or(ilike(schema.users.firstname, `%${criteria.lastname}%`), ilike(schema.users.lastname, `%${criteria.lastname}%`)));
// }
// return conditions;
// }
private getWhereConditions(criteria: UserListingCriteria): SQL[] {
const whereConditions: SQL[] = [];
@@ -161,25 +150,6 @@ export class UserService {
throw error;
}
}
// async findUser(criteria: UserListingCriteria) {
// const start = criteria.start ? criteria.start : 0;
// const length = criteria.length ? criteria.length : 12;
// const conditions = this.getConditions(criteria);
// const [data, total] = await Promise.all([
// this.conn
// .select()
// .from(schema.users)
// .where(and(...conditions))
// .offset(start)
// .limit(length),
// this.conn
// .select({ count: sql`count(*)` })
// .from(schema.users)
// .where(and(...conditions))
// .then(result => Number(result[0].count)),
// ]);
// return { total, data };
// }
async getStates(): Promise<any[]> {
const query = sql`SELECT jsonb_array_elements(${schema.users.areasServed}) ->> 'state' AS state, COUNT(DISTINCT ${schema.users.id}) AS count FROM ${schema.users} GROUP BY state ORDER BY count DESC`;
const result = await this.conn.execute(query);