BugFix: ERROR [ExceptionsHandler] column "users.areasServed" must appear in the GROUP BY clause or be used in an aggregate function resolved

This commit is contained in:
2024-09-04 18:15:16 +02:00
parent 7807afbad3
commit 9ecc0c2429
7 changed files with 2 additions and 97 deletions

View File

@@ -70,13 +70,6 @@ export class UserController {
findTotal(@Body() criteria: UserListingCriteria): Promise<number> {
return this.userService.getUserListingsCount(criteria);
}
@Get('states/all')
async getStates(): Promise<any[]> {
this.logger.info(`Getting all states for users`);
const result = await this.userService.getStates();
this.logger.info(`Found ${result.length} entries`);
return result;
}
@UseGuards(JwtAuthGuard)
@Get('subscriptions/:id')

View File

@@ -140,10 +140,4 @@ export class UserService {
throw error;
}
}
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);
return result.rows;
}
}