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

fetch TCOM decisions #155

Open
wants to merge 1 commit 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
4 changes: 2 additions & 2 deletions packages/courDeCassation/src/connector/fetcher/sderFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const sderFetcher = {
}: {
startDate: Date;
endDate: Date;
source: 'jurinet' | 'jurica' | 'juritj';
source: string;
}) {
const courtDecisions = await sderApi.fetchDecisionsToPseudonymiseBetween({
startDate,
Expand All @@ -46,7 +46,7 @@ const sderFetcher = {
}: {
startDate: Date;
endDate: Date;
source: 'jurinet' | 'jurica' | 'juritj';
source: string;
}) {
const courtDecisions = await sderApi.fetchDecisionsToPseudonymiseBetweenDateCreation(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async function mapCourtDecisionToDocument(
const NAOCode = sderCourtDecision.NAOCode || '';
const endCaseCode = sderCourtDecision.endCaseCode || '';

// TODO add title compute for TCOM
const title = computeTitleFromParsedCourtDecision({
source: source,
number: sderCourtDecision.sourceId,
Expand Down
4 changes: 2 additions & 2 deletions packages/courDeCassation/src/sderApi/sderApiType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type sderApiType = {
fetchDecisionsToPseudonymiseBetween: (param: {
startDate: Date;
endDate: Date;
source: 'jurinet' | 'jurica' | 'juritj';
source: string;
}) => Promise<Array<decisionType>>;
fetchDecisionsToPseudonymiseBetweenDateCreation: (param: {
startDate: Date;
endDate: Date;
source: 'jurinet' | 'jurica' | 'juritj';
source: string;
}) => Promise<Array<decisionType>>;
fetchCourtDecisionBySourceIdAndSourceName: (param: {
sourceId: decisionType['sourceId'];
Expand Down
35 changes: 35 additions & 0 deletions packages/generic/backend/src/lib/connector/buildConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,41 @@ function buildConnector(connectorConfig: connectorConfigType) {
data: error as Record<string, unknown>,
});
}
try {
logger.log({
operationName: 'importDocumentsSinceOrBetween',
msg: `Fetching ${connectorConfig.name} juritcom documents...`,
});
const newJuritcomCourtDecisions =
(byDateCreation
? await connectorConfig.fetchDecisionsToPseudonymiseBetweenDateCreation(
{
startDate: new Date(dateBuilder.daysAgo(fromDaysAgo)),
endDate: toDaysAgo
? new Date(dateBuilder.daysAgo(toDaysAgo))
: new Date(),
source: 'juritcom',
},
)
: await connectorConfig.fetchDecisionsToPseudonymiseBetween({
startDate: new Date(dateBuilder.daysAgo(fromDaysAgo)),
endDate: toDaysAgo
? new Date(dateBuilder.daysAgo(toDaysAgo))
: new Date(),
source: 'juritcom',
})) ?? [];
logger.log({
operationName: 'importDocumentsSinceOrBetween',
msg: `${newJuritcomCourtDecisions.length} ${connectorConfig.name} court decisions fetched from juritcom!`,
});
newCourtDecisions.push(...newJuritcomCourtDecisions);
} catch (error) {
logger.error({
operationName: 'importDocumentsSinceOrBetween',
msg: 'Error',
data: error as Record<string, unknown>,
});
}
const documents = [] as documentType[];
for (const courtDecision of newCourtDecisions) {
documents.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ type connectorConfigType = {
fetchDecisionsToPseudonymiseBetween(param: {
startDate: Date;
endDate: Date;
source: 'jurinet' | 'jurica' | 'juritj';
source: string;
}): Promise<decisionType[] | undefined>;
fetchDecisionsToPseudonymiseBetweenDateCreation(param: {
startDate: Date;
endDate: Date;
source: 'jurinet' | 'jurica' | 'juritj';
source: string;
}): Promise<decisionType[] | undefined>;
updateDocumentsLoadedStatus: (param: {
documents: documentType[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { AddWorkingUserDrawer };
const FIELD_WIDTH = 400;
const DRAWER_WIDTH = 600;

const sources = ['jurinet', 'jurica', 'juritj'];
const sources = ['jurinet', 'jurica', 'juritj', 'juritcom'];

type formErrorType = {
source?: boolean;
Expand Down
Loading