From 77c07c3ca05a14d27e98177b777fb77d63be21d7 Mon Sep 17 00:00:00 2001 From: Hugo <hnouts@grandlyon.com> Date: Thu, 28 May 2020 12:17:06 +0200 Subject: [PATCH] us 135 - working todo : activateHourLoad component isn't in the best place --- .../FluidChartContainer/FluidChartContainer.tsx | 8 ++++---- .../ContentComponents/FluidChart/FluidChartContent.tsx | 1 - src/services/consumptionDataManagerService.ts | 7 ++++--- src/services/queryRunnerService.ts | 5 +++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx b/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx index 37443b16f..9a414ff80 100644 --- a/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx +++ b/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx @@ -47,9 +47,9 @@ const FluidChartContainer: React.FC<FluidChartContainerProps> = ({ useEffect(() => { let subscribed = true async function loadData() { - const isMinute = await consumptionDataManager.checkDoctypeEntries( - fluidTypes, - timeStep + const halfHourLoad = await consumptionDataManager.checkDoctypeEntries( + FluidType.ELECTRICITY, + TimeStep.HALF_AN_HOUR ) const data = await consumptionDataManager.fetchLastDateData(fluidTypes) const dataWithAllFluids = await consumptionDataManager.fetchLastDateData( @@ -63,7 +63,7 @@ const FluidChartContainer: React.FC<FluidChartContainerProps> = ({ if (subscribed && dataWithAllFluids) { setLastDateWithAllData(dataWithAllFluids) } - if (subscribed && isMinute) { + if (subscribed && halfHourLoad) { setMinuteActive(true) } if (subscribed && currentChallenge) { diff --git a/src/components/ContentComponents/FluidChart/FluidChartContent.tsx b/src/components/ContentComponents/FluidChart/FluidChartContent.tsx index e13edcfbe..85228a569 100644 --- a/src/components/ContentComponents/FluidChart/FluidChartContent.tsx +++ b/src/components/ContentComponents/FluidChart/FluidChartContent.tsx @@ -67,7 +67,6 @@ const FluidChartContent: React.FC<FluidChartContentProps> = ({ currentChallenge.startingDate && currentChallenge.endingDate && new TimePeriod(currentChallenge.startingDate, currentChallenge.endingDate) - const handleChangeIndex = (index: number) => { const date = index === 0 diff --git a/src/services/consumptionDataManagerService.ts b/src/services/consumptionDataManagerService.ts index 26a51ea0e..ff2d6ec33 100644 --- a/src/services/consumptionDataManagerService.ts +++ b/src/services/consumptionDataManagerService.ts @@ -288,12 +288,13 @@ export default class ConsumptionDataManager implements IConsumptionDataManager { } public async checkDoctypeEntries( - fluideType: FluidType[], + fluideType: FluidType, timeStep: TimeStep ): Promise<boolean> { - //GET RELEVANT DOCTYPE - //QUERY RUNNER THIS DOCTYPE AND CHECK LENGTH const queryResult = await this._queryRunner.getEntries(fluideType, timeStep) + if (queryResult.length > 0) { + return true + } return false } diff --git a/src/services/queryRunnerService.ts b/src/services/queryRunnerService.ts index ccbe94a52..a5c0e2889 100644 --- a/src/services/queryRunnerService.ts +++ b/src/services/queryRunnerService.ts @@ -112,10 +112,11 @@ export class QueryRunner { return result } - public async getEntries(fluidType: FluidType[], timeStep: TimeStep) { + public async getEntries(fluidType: FluidType, timeStep: TimeStep) { let result = null + const doctype = this.getRelevantDoctype(fluidType, timeStep) try { - result = await this._client.find(ENEDIS_DAY_DOCTYPE).where({}) + result = await this._client.query(this._client.find(doctype).where({})) } catch (error) { return null } -- GitLab