Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface IQuery {
incidents(): Nullable<Incident>[] | Promise<Nullable<Incident>[]>;
incident(id: string): Nullable<Incident> | Promise<Nullable<Incident>>;
incidentsByServiceId(serviceId: string): Nullable<Incident>[] | Promise<Nullable<Incident>[]>;
filteredIncidents(status?: Nullable<string>, assigneeId?: Nullable<string>, organizationId?: Nullable<string>): Nullable<Incident>[] | Promise<Nullable<Incident>[]>;
incidentRoomURL(id: string): Nullable<string> | Promise<Nullable<string>>;
assignedIncidents(): Nullable<Incident>[] | Promise<Nullable<Incident>[]>;
openIncidents(): Nullable<Incident>[] | Promise<Nullable<Incident>[]>;
Expand Down
1 change: 1 addition & 0 deletions src/incidents/incidents.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Query {
incidents: [Incident]!
incident(id: ID!): Incident
incidentsByServiceId(serviceId: ID!): [Incident]!
filteredIncidents(status: String, assigneeId: String, organizationId: String): [Incident]!
incidentRoomURL(id: ID!): String
assignedIncidents: [Incident]!
openIncidents: [Incident]!
Expand Down
14 changes: 14 additions & 0 deletions src/incidents/incidents.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IncidentStatus } from './../graphql';
import { Resolver, Query, Mutation, Args } from '@nestjs/graphql';

import { IncidentsService } from './incidents.service';
Expand Down Expand Up @@ -37,6 +38,19 @@ export class IncidentsResolver {
return this.incidentsService.findAllByServiceId(serviceId);
}

@Query('filteredIncidents')
filteredIncidents(
@Args('status') status: IncidentStatus,
@Args('assigneeId') assigneeId: string,
@Args('organizationId') organizationId: string,
) {
return this.incidentsService.filterIncidents(
status,
assigneeId,
organizationId,
);
}

@Query('assignedIncidents')
assignedIncidents(@CurrentUser() user: User) {
return this.incidentsService.findAllByAssignedIncidents(user);
Expand Down
10 changes: 10 additions & 0 deletions src/incidents/incidents.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ export class IncidentsService {
});
}

async filterIncidents(
status: IncidentStatus,
assigneeId: string,
organizationId: string,
): Promise<Incident[]> {
return await this.db.incident.findMany({
where: { status, assigneeId, organizationId },
});
}

async findAllByAssignedIncidents(user: User): Promise<Incident[]> {
return await this.db.incident.findMany({
where: { assigneeId: user.id },
Expand Down