Skip to content

Commit

Permalink
fix default reading value check type being string
Browse files Browse the repository at this point in the history
  • Loading branch information
Trong Le committed Aug 9, 2023
1 parent 4ee7c63 commit 907dc69
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/client/app/actions/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ function fetchPreferences(): Thunk {
*/

function validPreferences(state: State) {
const MIN_VAL = Number.MIN_SAFE_INTEGER;
const MAX_VAL = Number.MAX_SAFE_INTEGER;
const MIN_VAL = Number.MIN_VALUE;
const MAX_VAL = Number.MAX_VALUE;
if (
state.admin.defaultMeterReadingGap >= 0 &&
state.admin.defaultMeterMinimumValue >= MIN_VAL &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone
Maximum No of Error must be between 0 and 75
*/
const [validMeter, setValidMeter] = useState(false);
const MIN_VAL = Number.MIN_SAFE_INTEGER;
const MAX_VAL = Number.MAX_SAFE_INTEGER;
const MIN_VAL = Number.MIN_VALUE;
const MAX_VAL = Number.MAX_VALUE;
const MIN_DATE_MOMENT = moment(0).utc();
const MAX_DATE_MOMENT = moment(0).utc().add(5000, 'years');
const MIN_DATE_STRING = moment(0).utc().format('YYYY-MM-DD HH:mm:ssZ');
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/components/meters/EditMeterModalComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr
Maximum No of Error must be between 0 and 75
*/
const [validMeter, setValidMeter] = useState(false);
const MIN_VAL = Number.MIN_SAFE_INTEGER;
const MAX_VAL = Number.MAX_SAFE_INTEGER;
const MIN_VAL = Number.MIN_VALUE;
const MAX_VAL = Number.MAX_VALUE;
const MIN_DATE_MOMENT = moment(0).utc();
const MAX_DATE_MOMENT = moment(0).utc().add(5000, 'years');
const MIN_DATE_STRING = moment(0).utc().format('YYYY-MM-DD HH:mm:ssZ');
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/reducers/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const defaultState: AdminState = {
defaultAreaNormalization: false,
defaultAreaUnit: AreaUnitType.none,
defaultMeterReadingFrequency: '00:15:00',
defaultMeterMinimumValue: Number.MIN_SAFE_INTEGER,
defaultMeterMaximumValue: Number.MAX_SAFE_INTEGER,
defaultMeterMinimumValue: Number.MIN_VALUE,
defaultMeterMaximumValue: Number.MAX_VALUE,
defaultMeterMinimumDate: moment(0).utc().format('YYYY-MM-DD HH:mm:ssZ'),
defaultMeterMaximumDate: moment(0).utc().add(5000, 'years').format('YYYY-MM-DD HH:mm:ssZ'),
defaultMeterReadingGap: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/server/sql/meter/create_meters_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ CREATE TABLE IF NOT EXISTS meters (
default_graphic_unit INTEGER REFERENCES units(id),
area_unit area_unit_type NOT NULL DEFAULT 'none',
reading_frequency INTERVAL NOT NULL DEFAULT '00:15:00',
min_val BIGINT NOT NULL DEFAULT -9007199254740991 CHECK (min_val::BIGINT >= -9007199254740991),
max_val BIGINT NOT NULL DEFAULT 9007199254740991 CHECK (max_val::BIGINT <= 9007199254740991),
min_val DOUBLE PRECISION NOT NULL DEFAULT 1E-307 CHECK (min_val::DOUBLE PRECISION >= 1E-307),
max_val DOUBLE PRECISION NOT NULL DEFAULT 1E+308 CHECK (max_val::DOUBLE PRECISION <= 1E+308),
min_date TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00+00:00',
max_date TIMESTAMP NOT NULL DEFAULT '6970-01-01 00:00:00+00:00',
max_error INTEGER NOT NULL DEFAULT 75,
Expand Down
4 changes: 2 additions & 2 deletions src/server/sql/preferences/create_preferences_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ CREATE TABLE IF NOT EXISTS preferences (
default_area_normalization BOOLEAN NOT NULL,
default_area_unit area_unit_type NOT NULL,
default_meter_reading_frequency INTERVAL NOT NULL,
default_meter_minimum_value BIGINT NOT NULL,
default_meter_maximum_value BIGINT NOT NULL,
default_meter_minimum_value DOUBLE PRECISION NOT NULL,
default_meter_maximum_value DOUBLE PRECISION NOT NULL,
default_meter_minimum_date TIMESTAMP NOT NULL,
default_meter_maximum_date TIMESTAMP NOT NULL,
default_meter_reading_gap REAL NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/server/sql/preferences/insert_default_row.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ IF NOT EXISTS(SELECT *
default_area_normalization, default_area_unit, default_meter_reading_frequency,
default_meter_minimum_value, default_meter_maximum_value, default_meter_minimum_date,
default_meter_maximum_date, default_meter_reading_gap, default_meter_maximum_errors)
VALUES ('', 'line', FALSE, 'en', NULL, 5, 25, FALSE, 'meters', '00:15:00', -9007199254740991, 9007199254740991, '1970-01-01 00:00:00+00:00', '6970-01-01 00:00:00+00:00', 0, 75);
VALUES ('', 'line', FALSE, 'en', NULL, 5, 25, FALSE, 'meters', '00:15:00', 1E-307, 1E+308, '1970-01-01 00:00:00+00:00', '6970-01-01 00:00:00+00:00', 0, 75);
END IF ;

END;
Expand Down

0 comments on commit 907dc69

Please sign in to comment.