-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get org ooo entries and filters/sort (#18645)
* feat: get org ooo entries and filters/sort * remove console.log --------- Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
- Loading branch information
1 parent
21694c0
commit 2aa3d1d
Showing
11 changed files
with
418 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...es/organizations/controllers/users/ooo/repositories/organizations-users-ooo.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service"; | ||
import { Injectable } from "@nestjs/common"; | ||
|
||
@Injectable() | ||
export class OrgUsersOOORepository { | ||
constructor(private readonly dbRead: PrismaReadService) {} | ||
async getOrgUsersOOOPaginated( | ||
orgId: number, | ||
skip: number, | ||
take: number, | ||
sort?: { sortStart?: "asc" | "desc"; sortEnd?: "asc" | "desc" }, | ||
filters?: { email?: string } | ||
) { | ||
console.log({ sort, filters }); | ||
return this.dbRead.prisma.outOfOfficeEntry.findMany({ | ||
where: { | ||
user: { | ||
...(filters?.email && { email: filters.email }), | ||
profiles: { | ||
some: { | ||
organizationId: orgId, | ||
}, | ||
}, | ||
}, | ||
}, | ||
skip, | ||
take, | ||
include: { reason: true }, | ||
...(sort?.sortStart && { orderBy: { start: sort.sortStart } }), | ||
...(sort?.sortEnd && { orderBy: { end: sort.sortEnd } }), | ||
}); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...rc/modules/organizations/controllers/users/ooo/services/organization-users-ooo.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { UserOOORepository } from "@/modules/ooo/repositories/ooo.repository"; | ||
import { UserOOOService } from "@/modules/ooo/services/ooo.service"; | ||
import { OrgUsersOOORepository } from "@/modules/organizations/controllers/users/ooo/repositories/organizations-users-ooo.repository"; | ||
import { UsersRepository } from "@/modules/users/users.repository"; | ||
import { Injectable } from "@nestjs/common"; | ||
|
||
@Injectable() | ||
export class OrgUsersOOOService { | ||
constructor( | ||
private readonly oooRepository: UserOOORepository, | ||
private readonly oooUserService: UserOOOService, | ||
private readonly usersRepository: UsersRepository, | ||
private readonly orgUsersOOORepository: OrgUsersOOORepository | ||
) {} | ||
|
||
async getOrgUsersOOOPaginated( | ||
orgId: number, | ||
skip: number, | ||
take: number, | ||
sort?: { sortStart?: "asc" | "desc"; sortEnd?: "asc" | "desc" }, | ||
filters?: { email?: string } | ||
) { | ||
const ooos = await this.orgUsersOOORepository.getOrgUsersOOOPaginated(orgId, skip, take, sort, filters); | ||
return ooos.map((ooo) => this.oooUserService.formatOooReason(ooo)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.