Skip to content

Commit

Permalink
Remove unused TaskService.getMatchTasks
Browse files Browse the repository at this point in the history
This code was presumably used when placement requests were assumed to individual users (making them tasks). This is no longer used so can be removed.
  • Loading branch information
davidatkinsuk committed Jan 27, 2025
1 parent a64f4c0 commit d1db86e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 61 deletions.
29 changes: 1 addition & 28 deletions server/services/taskService.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { CategorisedTask, PaginatedResponse } from '@approved-premises/ui'
import { PaginatedResponse } from '@approved-premises/ui'
import { Task, UserQualification } from '../@types/shared'
import TaskClient from '../data/taskClient'
import {
cruManagementAreaFactory,
paginatedResponseFactory,
placementApplicationTaskFactory,
placementRequestTaskFactory,
taskFactory,
taskWrapperFactory,
userWithWorkloadFactory,
Expand Down Expand Up @@ -72,31 +70,6 @@ describe('taskService', () => {
})
})

describe('getMatchTasks', () => {
it('calls the all method on the task client', async () => {
const applicationTasks = placementApplicationTaskFactory.buildList(1)
const notMatchedTasks = placementRequestTaskFactory.buildList(1, { placementRequestStatus: 'notMatched' })
const unableToMatchTasks = placementRequestTaskFactory.buildList(1, { placementRequestStatus: 'unableToMatch' })
const matchedTasks = placementRequestTaskFactory.buildList(1, { placementRequestStatus: 'matched' })

const tasks: Array<CategorisedTask> = [applicationTasks, notMatchedTasks, unableToMatchTasks, matchedTasks].flat()

taskClient.allForUser.mockResolvedValue(tasks)

const result = await service.getMatchTasks(token)

expect(result).toEqual({
notMatched: notMatchedTasks,
unableToMatch: unableToMatchTasks,
matched: matchedTasks,
placementApplications: applicationTasks,
})

expect(taskClientFactory).toHaveBeenCalledWith(token)
expect(taskClient.allForUser).toHaveBeenCalled()
})
})

describe('find', () => {
const applicationId = 'some-application-id'

Expand Down
34 changes: 1 addition & 33 deletions server/services/taskService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
Cas1CruManagementArea,
PlacementApplicationTask,
PlacementRequestTask,
Reallocation,
SortDirection,
Task,
Expand All @@ -11,7 +9,7 @@ import {
ApprovedPremisesUser as User,
UserQualification,
} from '@approved-premises/api'
import { GroupedMatchTasks, PaginatedResponse, TaskSearchQualification } from '@approved-premises/ui'
import { PaginatedResponse, TaskSearchQualification } from '@approved-premises/ui'
import { RestClientBuilder } from '../data'
import TaskClient from '../data/taskClient'

Expand Down Expand Up @@ -59,36 +57,6 @@ export default class TaskService {
})
}

async getMatchTasks(token: string): Promise<GroupedMatchTasks> {
const taskClient = this.taskClientFactory(token)

const tasks = await taskClient.allForUser()
const results = {
notMatched: [],
unableToMatch: [],
matched: [],
placementApplications: [],
} as GroupedMatchTasks

tasks.forEach(task => {
switch (task.taskType) {
case 'PlacementApplication': {
results.placementApplications.push(task as PlacementApplicationTask)
break
}
case 'PlacementRequest': {
const t = task as PlacementRequestTask
results[t.placementRequestStatus].push(t)
break
}
default:
break
}
})

return results
}

async find(
token: string,
premisesId: string,
Expand Down

0 comments on commit d1db86e

Please sign in to comment.