mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Query email to last createdAt for given event type
This commit is contained in:
parent
2369e682f5
commit
05e0ab1f7b
16
backend/src/graphql/resolver/util/eventList.ts
Normal file
16
backend/src/graphql/resolver/util/eventList.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { Event as DbEvent } from '@entity/Event'
|
||||
import { User } from '@entity/User'
|
||||
import { UserContact } from '@entity/UserContact'
|
||||
|
||||
export const lastDateTimeEvents = async (eventType: string): Promise<DbEvent[]> => {
|
||||
return DbEvent
|
||||
.createQueryBuilder('event')
|
||||
.select('MAX(event.created_at)', 'value')
|
||||
.leftJoin(User, 'user', 'affected_user_id = user.id')
|
||||
.leftJoin(UserContact, 'usercontact', 'user.id = usercontact.user_id')
|
||||
.addSelect('usercontact.email', 'email')
|
||||
.where('event.type = :eventType', { eventType })
|
||||
.andWhere('usercontact.email IS NOT NULL')
|
||||
.groupBy('event.affected_user_id')
|
||||
.getRawMany()
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user