diff --git a/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx b/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx index 37443b16f4a9888f2388e63a5d3fdbb9fc85fbb8..9a414ff802e4d328da2ade14cf7d6b563a7066f0 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 e13edcfbe2ef533840d1d15f7445d4677aba4668..85228a569052a40f4d0375dd118773be5a6a29c7 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 26a51ea0edcd004456cb609c778ca08420ec1ccf..ff2d6ec33e0e4b35a9c6df861ede69c0b3f33605 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 ccbe94a52b4794a2d264fb63edff1141c15e9e3e..a5c0e288929f68824fd7a3de26b09e0b49cc1182 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 }