Skip to content

Commit

Permalink
fetch TCOM decisions
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Jeanneney committed Dec 20, 2024
1 parent b4013ed commit e5407d0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
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

0 comments on commit e5407d0

Please sign in to comment.