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

Feat/Call dbsder-api to get route from metadata #121

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { extractRoute } from '.';

describe('extractRoute', () => {
it('should return exhaustive because it is juritj', async () => {
const route = extractRoute(
it('should return default because it is juritj', async () => {
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: '',
Expand All @@ -19,11 +19,11 @@ describe('extractRoute', () => {
'juritj',
);

expect(route).toBe('exhaustive');
expect(route).toBe('default');
});

it('should return default if no endCaseCode & no NACCode', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'non-admission',
Expand All @@ -44,7 +44,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if jurica with endCaseCode 44E & NACCode 10A', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'non-admission',
Expand All @@ -65,7 +65,7 @@ describe('extractRoute', () => {
});

it('should return automatic if jurica with endCaseCode 11A', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'non-admission',
Expand All @@ -86,7 +86,7 @@ describe('extractRoute', () => {
});

it('should return simple if jurica with NACCode 55L', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'non-admission',
Expand All @@ -107,7 +107,7 @@ describe('extractRoute', () => {
});

it('should return default if jurica with endCaseCode 33G (not in csv)', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'non-admission',
Expand All @@ -128,7 +128,7 @@ describe('extractRoute', () => {
});

it('should return automatic if NA', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'non-admission',
Expand All @@ -149,7 +149,7 @@ describe('extractRoute', () => {
});

it('should return confirmation if C', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -170,7 +170,7 @@ describe('extractRoute', () => {
});

it('should return confirmation if AVIS', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -191,7 +191,7 @@ describe('extractRoute', () => {
});

it('should return confirmation if Assemblée plénière', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -212,7 +212,7 @@ describe('extractRoute', () => {
});

it('should return confirmation if chambre mixte', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -233,7 +233,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if category published', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -254,7 +254,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if category published', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -275,7 +275,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if category published', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -296,7 +296,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if QPC', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -317,7 +317,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if QPC', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -338,7 +338,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if QPC', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'QPC incidente',
Expand All @@ -359,7 +359,7 @@ describe('extractRoute', () => {
});

it('should return automatic if Désistement', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Desistement par arret',
Expand All @@ -380,7 +380,7 @@ describe('extractRoute', () => {
});

it('should return automatic if Déchéance', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Decheance',
Expand All @@ -401,7 +401,7 @@ describe('extractRoute', () => {
});

it('should return simple if formation restreinte', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Cassation partielle',
Expand All @@ -422,7 +422,7 @@ describe('extractRoute', () => {
});

it('should return simple if Rejet non spécialement motivé', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand All @@ -443,7 +443,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if has additionalTermsToAnnotate', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: 'Something',
solution: 'Rejet non spécialement motivé',
Expand All @@ -464,7 +464,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if has more than 50 parties', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand Down Expand Up @@ -556,7 +556,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive if has more than 50 parties', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: '',
solution: 'Rejet non spécialement motivé',
Expand Down Expand Up @@ -648,7 +648,7 @@ describe('extractRoute', () => {
});

it('should return exhaustive even if Rejet non spécialement motivé because has additionalTermsToAnnotate', async () => {
const route = extractRoute(
const route = await extractRoute(
{
additionalTermsToAnnotate: 'Something',
solution: 'Rejet non spécialement motivé',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { documentType } from '@label/core';
import { extractRouteForJurica } from './extractRouteForJurica';
import { extractRouteForJurinet } from './extractRouteForJurinet';
import { extractRouteForJuritj } from './extractRouteForJuritj';
import { extractRouteForJuritcom } from './extractRouteForJuritcom';
import { Sources } from 'dbsder-api-types';

export { extractRoute };

function extractRoute(
async function extractRoute(
routeInfos: {
additionalTermsToAnnotate: documentType['decisionMetadata']['additionalTermsToAnnotate'];
session: documentType['decisionMetadata']['session'];
Expand All @@ -22,34 +24,27 @@ function extractRoute(
status?: documentType['status'];
},
source: documentType['source'],
): documentType['route'] {
): Promise<documentType['route']> {
let route: documentType['route'] = 'default';

switch (source) {
case 'jurinet':
try {
route = extractRouteForJurinet({ ...routeInfos });
} catch (e) {
logger.error({ operationName: 'extractRouteForJurinet', msg: `${e}` });
route = 'exhaustive';
}
break;
case 'jurica':
try {
route = extractRouteForJurica({ ...routeInfos });
} catch (e) {
logger.error({ operationName: 'extractRouteForJurica', msg: `${e}` });
route = 'exhaustive';
}
break;
case 'juritj':
try {
route = extractRouteForJuritj({ ...routeInfos });
} catch (e) {
logger.error({ operationName: 'extractRouteForJuritj', msg: `${e}` });
route = 'exhaustive';
}
break;
const extractRouteFunctions = {
[Sources.CC]: extractRouteForJurinet,
[Sources.CA]: extractRouteForJurica,
[Sources.TJ]: extractRouteForJuritj,
[Sources.TCOM]: extractRouteForJuritcom,
};

try {
if (source in extractRouteFunctions) {
route = await extractRouteFunctions[source as Sources]({
...routeInfos,
});
} else {
throw new Error('Source non prise en charge');
}
} catch (e) {
logger.error({ operationName: `extractRouteFor ${source}`, msg: `${e}` });
route = 'default';
}

if (
Expand Down
Loading
Loading