Skip to content

Commit

Permalink
feat: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlr committed Jul 9, 2024
1 parent 422ba38 commit 4df9c50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions server/src/modules/jobs/deca/hydrate-deca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const buildDecaContract = (contrat: any) => {
};
};

export const shouldStopCallingDeca = ({
export const isDecaApiAvailable = ({
forceStartHour,
forceProductionEnvironment,
}: {
Expand Down Expand Up @@ -156,7 +156,7 @@ export const hydrateDeca = async ({ from, to }: { from?: string; to?: string })
const periods = await buildPeriodsToFetch(dateDebutToFetch, dateFinToFetch);

await asyncForEach(periods, async ({ dateDebut, dateFin }: { dateDebut: string; dateFin: string }) => {
if (shouldStopCallingDeca({})) {
if (isDecaApiAvailable({})) {
return;
}

Expand Down
16 changes: 6 additions & 10 deletions server/tests/unit/deca.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import { afterAll, beforeAll, beforeEach, describe, it } from "vitest";
import { getDbVerification, importDecaContent, parseContentLine } from "../../src/modules/actions/deca.actions";
import { findOrganisations } from "../../src/modules/actions/organisations.actions";
import { findPersons } from "../../src/modules/actions/persons.actions";
import {
buildDecaContract,
buildPeriodsToFetch,
shouldStopCallingDeca,
} from "../../src/modules/jobs/deca/hydrate-deca";
import { buildDecaContract, buildPeriodsToFetch, isDecaApiAvailable } from "../../src/modules/jobs/deca/hydrate-deca";
import { deepFlattenToObject } from "../../src/modules/jobs/deca/hydrate-deca-history";
import { useMongo } from "../utils/mongo.utils";

Expand Down Expand Up @@ -361,11 +357,11 @@ describe("IMPORT DECA from API", () => {
});

it("should not start when time is over", async () => {
assert.equal(shouldStopCallingDeca({ forceStartHour: 6, forceProductionEnvironment: "forceProduction" }), true);
assert.equal(shouldStopCallingDeca({ forceStartHour: 19, forceProductionEnvironment: "forceProduction" }), true);
assert.equal(shouldStopCallingDeca({ forceStartHour: 12, forceProductionEnvironment: "forceProduction" }), true);
assert.equal(shouldStopCallingDeca({ forceStartHour: 5, forceProductionEnvironment: "forceProduction" }), false);
assert.equal(shouldStopCallingDeca({ forceStartHour: 20, forceProductionEnvironment: "forceProduction" }), false);
assert.equal(isDecaApiAvailable({ forceStartHour: 6, forceProductionEnvironment: "forceProduction" }), true);
assert.equal(isDecaApiAvailable({ forceStartHour: 19, forceProductionEnvironment: "forceProduction" }), true);
assert.equal(isDecaApiAvailable({ forceStartHour: 12, forceProductionEnvironment: "forceProduction" }), true);
assert.equal(isDecaApiAvailable({ forceStartHour: 5, forceProductionEnvironment: "forceProduction" }), false);
assert.equal(isDecaApiAvailable({ forceStartHour: 20, forceProductionEnvironment: "forceProduction" }), false);
});

it("deepFlattenToObject works as expected", async () => {
Expand Down

0 comments on commit 4df9c50

Please sign in to comment.