From 750bad12871e6008748c2287ba8cf4a9d2c6af32 Mon Sep 17 00:00:00 2001 From: nmqng Date: Thu, 3 Oct 2024 00:36:59 -0400 Subject: [PATCH] fix syntax, code style based on run check --- .../redux/selectors/chartQuerySelectors.ts | 22 +-- .../app/redux/selectors/lineChartSelectors.ts | 2 +- src/client/app/types/redux/graph.ts | 159 +++++++++--------- 3 files changed, 91 insertions(+), 92 deletions(-) diff --git a/src/client/app/redux/selectors/chartQuerySelectors.ts b/src/client/app/redux/selectors/chartQuerySelectors.ts index 92735c502..c4d863995 100644 --- a/src/client/app/redux/selectors/chartQuerySelectors.ts +++ b/src/client/app/redux/selectors/chartQuerySelectors.ts @@ -92,17 +92,17 @@ export const selectCompareLineQueryArgs = createSelector( const args: CompareLineReadingApiArgs = threeD.meterOrGroup === MeterOrGroup.meters ? { - ids: [threeD.meterOrGroupID!], - timeInterval: queryTimeInterval.toString(), - graphicUnitId: selectedUnit, - meterOrGroup: threeD.meterOrGroup!, - } + ids: [threeD.meterOrGroupID!], + timeInterval: queryTimeInterval.toString(), + graphicUnitId: selectedUnit, + meterOrGroup: threeD.meterOrGroup! + } : { - ids: [threeD.meterOrGroupID!], - timeInterval: queryTimeInterval.toString(), - graphicUnitId: selectedUnit, - meterOrGroup: threeD.meterOrGroup!, - }; + ids: [threeD.meterOrGroupID!], + timeInterval: queryTimeInterval.toString(), + graphicUnitId: selectedUnit, + meterOrGroup: threeD.meterOrGroup! + }; const shouldSkipQuery = !threeD.meterOrGroupID || !queryTimeInterval.getIsBounded(); const argsDeps = threeD.meterOrGroup === MeterOrGroup.meters ? lineChartDeps.meterDeps : lineChartDeps.groupDeps; return { args, shouldSkipQuery, argsDeps }; @@ -220,6 +220,6 @@ export const selectAllChartQueryArgs = createSelector( compare, map, threeD, - compareLine, + compareLine }) ); diff --git a/src/client/app/redux/selectors/lineChartSelectors.ts b/src/client/app/redux/selectors/lineChartSelectors.ts index 2976e26c6..b69ec7b28 100644 --- a/src/client/app/redux/selectors/lineChartSelectors.ts +++ b/src/client/app/redux/selectors/lineChartSelectors.ts @@ -45,7 +45,7 @@ export const selectPlotlyMeterData = selectFromLineReadingsResult( const yMinData: number[] = []; const yMaxData: number[] = []; const hoverText: string[] = []; - + // The scaling is the factor to change the reading by. It divides by the area while will be 1 if no scaling by area. readings.forEach(reading => { // As usual, we want to interpret the readings in UTC. We lose the timezone as this as the start/endTimestamp diff --git a/src/client/app/types/redux/graph.ts b/src/client/app/types/redux/graph.ts index 5bc6d34dd..5cfb34610 100644 --- a/src/client/app/types/redux/graph.ts +++ b/src/client/app/types/redux/graph.ts @@ -2,88 +2,87 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - import * as moment from 'moment'; - import { TimeInterval } from '../../../../common/TimeInterval'; - import { ComparePeriod, SortingOrder } from '../../utils/calculateCompare'; - import { AreaUnitType } from '../../utils/getAreaUnitConversion'; - - export enum ChartTypes { - line = 'line', - bar = 'bar', - compare = 'compare', - map = 'map', - radar = 'radar', - threeD = '3D', - compareLine = 'compare.line' - } - - // Rates that can be graphed, only relevant to line graphs. - export const LineGraphRates = { - 'second': (1 / 3600), - 'minute': (1 / 60), - 'hour': 1, - 'day': 24 - }; - - // Use to determine readings per day on 3D Graphs - // 24 / ReadingInterval.Hourly(1) = 24 readings per day @ 1 hour intervals - // 24 / ReadingInterval.TwoHour(2) = 12 readings per day @ 2 hour intervals - // and so on. - export enum ReadingInterval { - Hourly = 1, - TwoHour = 2, - ThreeHour = 3, - FourHour = 4, - SixHour = 6, - EightHour = 8, - TwelveHour = 12, - Incompatible = -999 - } - - - export interface LineGraphRate { - label: string, - rate: number - } - - export type MeterOrGroupID = number; - export enum MeterOrGroup { meters = 'meters', groups = 'groups' } - export type MeterOrGroupPill = { meterOrGroupID: number, isDisabled: boolean, meterOrGroup: MeterOrGroup } - - export interface ThreeDState { - meterOrGroupID: MeterOrGroupID | undefined; - meterOrGroup: MeterOrGroup | undefined; - readingInterval: ReadingInterval; - } - - export enum ShiftAmount { +import * as moment from 'moment'; +import { TimeInterval } from '../../../../common/TimeInterval'; +import { ComparePeriod, SortingOrder } from '../../utils/calculateCompare'; +import { AreaUnitType } from '../../utils/getAreaUnitConversion'; + +export enum ChartTypes { + line = 'line', + bar = 'bar', + compare = 'compare', + map = 'map', + radar = 'radar', + threeD = '3D', + compareLine = 'compare.line' +} + +// Rates that can be graphed, only relevant to line graphs. +export const LineGraphRates = { + 'second': (1 / 3600), + 'minute': (1 / 60), + 'hour': 1, + 'day': 24 +}; + +// Use to determine readings per day on 3D Graphs +// 24 / ReadingInterval.Hourly(1) = 24 readings per day @ 1 hour intervals +// 24 / ReadingInterval.TwoHour(2) = 12 readings per day @ 2 hour intervals +// and so on. +export enum ReadingInterval { + Hourly = 1, + TwoHour = 2, + ThreeHour = 3, + FourHour = 4, + SixHour = 6, + EightHour = 8, + TwelveHour = 12, + Incompatible = -999 +} + + +export interface LineGraphRate { + label: string, + rate: number +} + +export type MeterOrGroupID = number; +export enum MeterOrGroup { meters = 'meters', groups = 'groups' } +export type MeterOrGroupPill = { meterOrGroupID: number, isDisabled: boolean, meterOrGroup: MeterOrGroup } + +export interface ThreeDState { + meterOrGroupID: MeterOrGroupID | undefined; + meterOrGroup: MeterOrGroup | undefined; + readingInterval: ReadingInterval; +} + +export enum ShiftAmount { week = 'week', month = 'month', year = 'year', custom = 'custom', none = 'none' - } - - export interface GraphState { - areaNormalization: boolean; - selectedMeters: number[]; - selectedGroups: number[]; - selectedUnit: number; - selectedAreaUnit: AreaUnitType; - rangeSliderInterval: TimeInterval; - barDuration: moment.Duration; - mapsBarDuration: moment.Duration; - comparePeriod: ComparePeriod; - compareTimeInterval: TimeInterval; - compareSortingOrder: SortingOrder; - chartToRender: ChartTypes; - barStacking: boolean; - lineGraphRate: LineGraphRate; - showMinMax: boolean; - threeD: ThreeDState; - queryTimeInterval: TimeInterval; - hotlinked: boolean; - shiftAmount: ShiftAmount; - shiftTimeInterval: TimeInterval; - } - \ No newline at end of file +} + +export interface GraphState { + areaNormalization: boolean; + selectedMeters: number[]; + selectedGroups: number[]; + selectedUnit: number; + selectedAreaUnit: AreaUnitType; + rangeSliderInterval: TimeInterval; + barDuration: moment.Duration; + mapsBarDuration: moment.Duration; + comparePeriod: ComparePeriod; + compareTimeInterval: TimeInterval; + compareSortingOrder: SortingOrder; + chartToRender: ChartTypes; + barStacking: boolean; + lineGraphRate: LineGraphRate; + showMinMax: boolean; + threeD: ThreeDState; + queryTimeInterval: TimeInterval; + hotlinked: boolean; + shiftAmount: ShiftAmount; + shiftTimeInterval: TimeInterval; +}