Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIC-3697 Fix performance of bulk defendant matching #896

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
} = require('../config')
const { updateSelectedCourts } = require('../services/user-preference-service')
const {
getCaseList,
getCaseListForBulkMatching,
getMatchDetails,
deleteOffender,
updateOffender,
Expand Down Expand Up @@ -760,7 +760,7 @@ module.exports = function Index ({ authenticationMiddleware }) {
session,
params
} = req
const response = await getCaseList(courtCode, date)
const response = await getCaseListForBulkMatching(courtCode, date)
const templateValues = {
title: 'Defendants with possible NDelius records',
session: {
Expand Down
17 changes: 16 additions & 1 deletion server/services/case-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,20 @@ const createCaseService = apiUrl => {
)) || { data: {} }
return res.data
},
getPagedCaseList: async (
getCaseListForBulkMatching: async (
courtCode,
date
) => {
const apiUrlBuilder = new URL(`${apiUrl}/court/${courtCode}/cases`)

apiUrlBuilder.searchParams.append('date', date)
apiUrlBuilder.searchParams.append('VERSION2', 'true')
apiUrlBuilder.searchParams.append('page', '1')
apiUrlBuilder.searchParams.append('size', '1000') // to fetch all cases wiht possible NDelius records and ignore paging
apiUrlBuilder.searchParams.append('probationStatus', 'Possible NDelius record')

},
getPagedCaseList: async (
courtCode,
date,
selectedFilters,
Expand Down Expand Up @@ -168,6 +181,8 @@ const createCaseService = apiUrl => {
filters: caseListFilters
}
},
// TODO this should be avoided / deleted
// Deprecated
getCaseList: async (courtCode, date, selectedFilters, subsection) => {
const latestSnapshot = getLatestSnapshot(date).format(
'YYYY-MM-DDTHH:mm:00.000'
Expand Down
5 changes: 3 additions & 2 deletions server/views/match-records.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
} %}

{% for item in data %}
{% if (item.probationStatus | string | lower == "possible ndelius record") and (item.numberOfPossibleMatches | int > 0) %}
{# below check is unnecessary as the endpoint now only returns cases with possible NDelius records #}
{# {% if (item.probationStatus | string | lower == "possible ndelius record") and (item.numberOfPossibleMatches | int > 0) %}#}
{% set defendantFullName = (item.name.forename1 + ' ' + item.name.surname) if (item.name.forename1 and item.name.surname) else item.defendantName %}
{%- set tableRow = [
{ text: defendantFullName | escape | apostropheInName | properCase | removeTitle },
{ text: item.numberOfPossibleMatches | escape },
{ text: ('<a href="/' + params.courtCode + '/case/' + item.caseId + '/hearing/' + (item.hearingId | escape) + '/match/defendant/' + (item.defendantId | escape) +'" class="pac-defendant-link govuk-link govuk-link--no-visited-state">Review records</a>') | safe }
] -%}
{{ tableData.rows.push(tableRow) }}
{% endif %}
{# {% endif %}#}
{% endfor %}

{% block backlink %}
Expand Down