Skip to content

Commit

Permalink
Revert "MAP-1625 get report using db query that doesn't require user (#…
Browse files Browse the repository at this point in the history
…726)"

This reverts commit acea4e5.
  • Loading branch information
GurnankCheema committed Oct 16, 2024
1 parent acea4e5 commit 6d3a1f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion server/routes/adhocReportActions/addhocActionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class AddhocActionController {

for (let reportId = fromId; reportId <= toId; reportId += 1) {
try {
const report = await this.reportService.getReportUsingReportIdOnly(reportId)
const report = await this.reportService.getReport(req.user.username, reportId)

const { locationId } = report.form.incidentDetails

Expand Down
14 changes: 7 additions & 7 deletions server/routes/adhocReportActions/adhocActionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ describe('Adhoc actions', () => {
it('calls the report service to get reports correctly', async () => {
await controller.updateReport(req, res)

expect(reportService.getReportUsingReportIdOnly).toHaveBeenCalledTimes(2)
expect(reportService.getReportUsingReportIdOnly).toHaveBeenCalledWith(1)
expect(reportService.getReportUsingReportIdOnly).toHaveBeenCalledWith(2)
expect(reportService.getReport).toHaveBeenCalledTimes(2)
expect(reportService.getReport).toHaveBeenCalledWith('user_name', 1)
expect(reportService.getReport).toHaveBeenCalledWith('user_name', 2)
})

it('does not do update if incidentLocationId already exists', async () => {
Expand All @@ -75,7 +75,7 @@ describe('Adhoc actions', () => {
},
}

reportService.getReportUsingReportIdOnly.mockResolvedValue(report as any)
reportService.getReport.mockResolvedValue(report as any)
await controller.updateReport(req, res)

expect(reportService.update).not.toHaveBeenCalled()
Expand All @@ -95,8 +95,8 @@ describe('Adhoc actions', () => {
},
}

reportService.getReportUsingReportIdOnly.mockResolvedValueOnce(report as any)
reportService.getReportUsingReportIdOnly.mockRejectedValueOnce(Error(`Report does not exist: 2`))
reportService.getReport.mockResolvedValueOnce(report as any)
reportService.getReport.mockRejectedValueOnce(Error(`Report does not exist: 2`))

nomisMappingService.getDpsLocationDetailsHavingCorrespondingNomisLocationId.mockResolvedValue({
dpsLocationId: 'some-uuid',
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('Adhoc actions', () => {
},
}

reportService.getReportUsingReportIdOnly.mockResolvedValue(report as any)
reportService.getReport.mockResolvedValue(report as any)

nomisMappingService.getDpsLocationDetailsHavingCorrespondingNomisLocationId.mockResolvedValue({
dpsLocationId: 'some-uuid',
Expand Down
9 changes: 0 additions & 9 deletions server/services/reportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ export default class ReportService {
return report
}

async getReportUsingReportIdOnly(reportId: number): Promise<Report> {
const report = await this.incidentClient.getReportForReviewer(reportId)

if (!report) {
throw new Error(`Report does not exist: ${reportId}`)
}
return report
}

async getAnonReportSummary(token: string, statementId: number): Promise<AnonReportSummaryWithPrison | undefined> {
const report = await this.incidentClient.getAnonReportSummary(statementId)
if (!report) {
Expand Down

0 comments on commit 6d3a1f1

Please sign in to comment.