Skip to content

Commit

Permalink
chore: minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Jun 11, 2023
1 parent 38cf334 commit c40b019
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
17 changes: 8 additions & 9 deletions apps/api/src/controllers/leo/bureau-of-firearms-controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WhitelistStatus } from "@prisma/client";
import { Prisma, WhitelistStatus } from "@prisma/client";
import { BodyParams, PathParams, QueryParams, UseBeforeEach } from "@tsed/common";
import { Controller } from "@tsed/di";
import { BadRequest, NotFound } from "@tsed/exceptions";
Expand All @@ -14,6 +14,11 @@ import type * as APITypes from "@snailycad/types/api";
import { IsFeatureEnabled, Feature } from "middlewares/is-enabled";
import { citizenInclude } from "controllers/citizen/CitizenController";

const includes = Prisma.validator<Prisma.WeaponSelect>()({
...citizenInclude.weapons.include,
citizen: true,
});

@Controller("/leo/bureau-of-firearms")
@UseBeforeEach(IsAuth)
@ContentType("application/json")
Expand All @@ -32,10 +37,7 @@ export class BureauOfFirearmsController {
prisma.weapon.count({ where: { bofStatus: { not: null } } }),
prisma.weapon.findMany({
where: { bofStatus: { not: null } },
include: {
...citizenInclude.weapons.include,
citizen: true,
},
include: includes,
orderBy: { createdAt: "desc" },
take: includeAll ? undefined : 35,
skip: includeAll ? undefined : skip,
Expand Down Expand Up @@ -66,10 +68,7 @@ export class BureauOfFirearmsController {
const updated = await prisma.weapon.update({
where: { id: weapon.id },
data: { bofStatus },
include: {
...citizenInclude.weapons.include,
citizen: true,
},
include: includes,
});

return updated;
Expand Down
6 changes: 6 additions & 0 deletions apps/api/src/lib/leo/records/upsert-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ export async function upsertRecord(options: UpsertRecordOptions) {
);

if (Object.keys(errors).length >= 1) {
captureException({
name: "InvalidViolations",
message: "Invalid violations appended to record",
violations: JSON.stringify(errors),
});

await prisma.record.delete({ where: { id: ticket.id } });
throw new ExtendedBadRequest(errors);
}
Expand Down
3 changes: 3 additions & 0 deletions apps/client/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ init({
"Hydration failed because the initial UI does not match what was rendered on the server.",
"Cannot have two HTML5 backends at the same time.",
/Cannot resolve a DOM point from Slate point:/gi,
/Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node./gi,
"Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.",
"The object can not be found here.",
],
integrations(integrations) {
return [...integrations, new BrowserTracing()];
Expand Down
3 changes: 3 additions & 0 deletions apps/client/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ init({
"Hydration failed because the initial UI does not match what was rendered on the server.",
"Cannot have two HTML5 backends at the same time.",
/Cannot resolve a DOM point from Slate point:/gi,
/Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node./gi,
"Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.",
"The object can not be found here.",
],
});
3 changes: 3 additions & 0 deletions apps/client/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ init({
"Hydration failed because the initial UI does not match what was rendered on the server.",
"Cannot have two HTML5 backends at the same time.",
/Cannot resolve a DOM point from Slate point:/gi,
/Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node./gi,
"Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.",
"The object can not be found here.",
],
});

0 comments on commit c40b019

Please sign in to comment.