chore: add new route to get users of services
This commit is contained in:
@@ -244,6 +244,31 @@ export class DanakServicesService {
|
||||
}
|
||||
/******************************************** */
|
||||
|
||||
async getServiceUsers(serviceId: string) {
|
||||
await this.findServiceById(serviceId);
|
||||
|
||||
const users = await this.danakServicesRepository
|
||||
.createQueryBuilder("service")
|
||||
.innerJoin("service.subscriptionPlans", "subscriptionPlans")
|
||||
.innerJoin("subscriptionPlans.userSubscriptions", "userSubscriptions")
|
||||
.innerJoin("user", "user", "userSubscriptions.userId = user.id")
|
||||
.select([
|
||||
"DISTINCT user.id AS id",
|
||||
"user.firstName AS firstName",
|
||||
"user.lastName AS lastName",
|
||||
"user.email AS email",
|
||||
"user.profilePic AS profilePic",
|
||||
])
|
||||
.where("service.id = :serviceId", { serviceId })
|
||||
.andWhere("userSubscriptions.status = :status", { status: SubscriptionStatus.ACTIVE })
|
||||
.andWhere("userSubscriptions.endDate > NOW()")
|
||||
.getRawMany();
|
||||
|
||||
return { users };
|
||||
}
|
||||
|
||||
/******************************************** */
|
||||
|
||||
async getDanakServiceReviews(queryDto: DanakServiceReviewQueryDto) {
|
||||
const { limit, skip } = PaginationUtils(queryDto);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user