This is a collect of information on useful SQL commands for looking at the database and for using with testing for correct functioning. It can allow for loading of special data to see how it functions. It also shows SQL commands that my be interesting and useful in other contexts and modifiable.
It is provided for the record and for potential use. Some items may be out of date or have issues as they have not been retested. Some assume the basic test data has been loaded.
This is only the first version with limited information. More should be coming in the future. If you have ideas for additions/changes then please make a pull request.
- Remove all readings, groups, meters, conversions, units and the cik data.
delete from readings;
delete from groups_immediate_meters;
delete from groups_immediate_children;
delete from groups;
delete from meters;
delete from conversion_segments;
delete from conversions;
delete from cik;
delete from cik_vary;
delete from units;- Purge suffix units. Works after time-varying work.
DELETE FROM CONVERSION_SEGMENTS WHERE DESTINATION_ID IN ( SELECT ID FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix' );
DELETE FROM CONVERSION_SEGMENTS WHERE SOURCE_ID IN ( SELECT ID FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix' );
DELETE FROM CONVERSIONS WHERE DESTINATION_ID IN ( SELECT ID FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix' );
DELETE FROM CONVERSIONS WHERE SOURCE_ID IN ( SELECT ID FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix' );
DELETE FROM CIK;
DELETE FROM READINGS WHERE METER_ID IN ( SELECT ID FROM METERS WHERE DEFAULT_GRAPHIC_UNIT IN ( SELECT ID FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix' ) );
DELETE FROM METERS WHERE DEFAULT_GRAPHIC_UNIT IN ( SELECT ID FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix' );
DELETE FROM UNITS WHERE SUFFIX != '' OR TYPE_OF_UNIT = 'suffix';- Remove the readings, meters/groups, units & ciks associated with the Water Gallon/gallon test data.
DELETE FROM READINGS WHERE METER_ID NOT IN ( SELECT ID FROM METERS WHERE NAME = 'Water Gallon');
delete from groups_immediate_meters;
delete from groups_immediate_children;
delete from groups;
DELETE FROM METERS WHERE ID NOT IN ( SELECT ID FROM METERS WHERE NAME = 'Water Gallon');
DELETE FROM CIK WHERE SOURCE_ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) OR DESTINATION_ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );
DELETE FROM CIK_VARY WHERE SOURCE_ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) OR DESTINATION_ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );
DELETE FROM UNITS WHERE ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) AND ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );- Remove all units, conversions, ... but the water ones. Probably easier to delete them all and just recreate ones wanted.
DELETE FROM CONVERSION_SEGMENTS WHERE SOURCE_ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) OR DESTINATION_ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );
DELETE FROM CONVERSIONS WHERE SOURCE_ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) OR DESTINATION_ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );
-- I made a mistake and did METER_UNIT for ID select so had to remove all readings since ones wanted were gone.
DELETE FROM READINGS WHERE METER_ID NOT IN ( SELECT ID FROM METERS WHERE NAME = 'Water Gallon');
delete from groups_immediate_meters;
delete from groups_immediate_children;
delete from groups;
DELETE FROM METERS WHERE ID NOT IN ( SELECT ID FROM METERS WHERE NAME = 'Water Gallon');
DELETE FROM CIK WHERE SOURCE_ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) OR DESTINATION_ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );
DELETE FROM CIK_VARY WHERE SOURCE_ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) OR DESTINATION_ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );
DELETE FROM UNITS WHERE ID NOT IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) AND ID NOT IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' );- Make water (see previous example) have 2 segments (no pattern) where removal all other ones if they exist:
DELETE FROM CIK;
DELETE FROM CIK_VARY;
DELETE FROM CONVERSION_SEGMENTS;
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ), ( SELECT ID FROM UNITS WHERE NAME = 'gallon' ), NULL, 2, 0, '-infinity', '2021-06-03 00:00:00', 'segment 1 Water Gallon -> gallon' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ), ( SELECT ID FROM UNITS WHERE NAME = 'gallon' ), NULL, 3, 0, '2021-06-03 00:00:00', 'infinity', 'segment 2 Water Gallon -> gallon' );- Change the end time of the one segment of the test data for Water Gallon/gallon.
UPDATE CONVERSION_SEGMENTS SET END_TIME = '2021-06-06 00:00:00' WHERE SOURCE_ID IN ( SELECT UNIT_ID FROM METERS WHERE NAME = 'Water Gallon' ) AND DESTINATION_ID IN ( SELECT ID FROM UNITS WHERE NAME = 'gallon' ) AND START_TIME = '-infinity' AND END_TIME = 'infinity';- This is a reasonable test case with patterns (weeks) and slope/intercept that overlap. Here is a description:
- um1: meter unit
- ug2: first graphic unit
- ug3: second graphic unit
- ug4: third graphic unit
um1 -> ug2 <-> ug3 <-> ug4
- d1 (1 hour segment at end)
| Hours | slope (intercept 0) |
|---|---|
| 0-7 | 2 |
| 7-23 | 3 |
| 23-24 | 5 |
- d2 (span the whole day)
| Hours | slope (intercept 0) |
|---|---|
| 0-24 | 7 |
- d3 (split day evenly)
| Hours | slope (intercept 0) |
|---|---|
| 0-12 | 13 |
| 12-24 | 17 |
- w1
| Week | Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|---|
| w1 | d2 | d1 | d2 | d2 | d2 | d1 | d2 |
- w2 (all days the same)
| Week | Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|---|
| w1 | d3 | d3 | d3 | d3 | d3 | d3 | d3 |
-inf 6/3 6/4 6/6 6/7 6/10 6/16 6/17 inf
| 10 | w1 | 20 | 30 | um1 -> ug2
| 40 | 50 | 60 | 70 | ug2 <-> ug3
| 80 | w2 | 90 | ug3 <-> ug4
When cik_vary is redone, it should show the values shown here:
| end of segment hour | expected value | Note |
|---|---|---|
| 6/3/2020 00 | 10 | many days |
| 6/4/2020 00 | 7 | W, d2 |
| 6/5/2020 00 | 7 | R, d2 |
| 6/5/2020 07 | 2 | F, d1 |
| 6/5/2020 23 | 3 | F, d1 |
| 6/6/2020 00 | 7 | F, d1 |
| 6/7/2020 00 | 5 | S, d2 |
| 6/16/2020 07 | 20 | |
| infinity | 30 |
| end of segment hour | expected value | Note |
|---|---|---|
| 6/3/2020 00 | 400 | many days |
| 6/4/2020 00 | 280 | W, d2 |
| 6/5/2020 00 | 350 | R, d2 |
| 6/5/2020 07 | 100 | F, d1 |
| 6/5/2020 23 | 150 | F, d1 |
| 6/6/2020 00 | 250 | F, d1 |
| 6/7/2020 00 | 350 | S, d2 |
| 6/10/2020 00 | 1000 | |
| 6/16/2020 07 | 1200 | |
| 6/17/2020 23 | 1800 | |
| infinity | 2100 |
| end of segment hour | expected value | Note |
|---|---|---|
| 6/3/2020 00 | 32,000 | many days |
| 6/4/2020 00 | 22,400 | W, d2 |
| 6/5/2020 00 | 28,000 | R, d2 |
| 6/5/2020 07 | 8000 | F, d1 |
| 6/5/2020 23 | 12,000 | F, d1 |
| 6/6/2020 00 | 20,000 | F, d1 |
| 6/6/2020 12 | 4,550 | d3 |
| 6/7/2020 00 | 5,950 | d3 |
| 6/7/2020 12 | 13,000 | d3, repeats until 6/9 |
| 6/8/2020 00 | 17,000 | d3, repeats until 6/10 |
| 6/10/2020 12 | 15,600 | d3, repeats until 6/16 |
| 6/11/2020 00 | 20,400 | d3, repeats until 6/17 |
| 6/16/2020 12 | 23,400 | d3 |
| 6/17/2020 00 | 30,600 | d3 |
| infinity | 189,000 |
-- see data
select * from meters;
select * from units;
select * from week_patterns;
select * from day_patterns;
select * from day_segments;
select * from conversions order by source_id, destination_id;
select * from conversion_segments order by source_id, destination_id;
select * from cik order by source_id, destination_id;
-- Also show name of source & destination units
select (select name from units where id = source_id), (select name from units where id = destination_id), * from cik order by source_id, destination_id;
select * from cik_vary order by source_id, destination_id;
select * from cik_vary order by destination_id, start_time;
-- Also show name of source & destination units
select (select name from units where id = source_id), (select name from units where id = destination_id), * from cik_vary order by source_id, destination_id;
-- Remove data
delete from meters;
delete from conversion_segments;
delete from conversions;
delete from week_patterns;
delete from day_patterns;
delete from day_segments;
delete from cik;
delete from cik_vary;
delete from units;
-- Week 1
-- day pattern
insert into day_patterns values (DEFAULT, 'dp1', 'for ds2, ds3, ds5');
insert into day_patterns values (DEFAULT, 'dp2', 'for ds7');
-- day segments
insert into day_segments values (DEFAULT, ( SELECT id FROM day_patterns WHERE NAME = 'dp1' ), 0, 7, 2, 0, 'd2 for dp1 0-7 slope 2');
insert into day_segments values (DEFAULT, ( SELECT id FROM day_patterns WHERE NAME = 'dp1' ), 7, 23, 3, 0, 'd3 for dp1 7-23 slope 3');
insert into day_segments values (DEFAULT, ( SELECT id FROM day_patterns WHERE NAME = 'dp1' ), 23, 24, 5, 0, 'd5 for dp1 23-24 slope 5');
insert into day_segments values (DEFAULT, ( SELECT id FROM day_patterns WHERE NAME = 'dp2' ), 0, 24, 7, 0, 'd7 for dp2 0-24 slope 7');
--- week pattern
insert into week_patterns values (DEFAULT, 'w1', 'dp1: M, F; dp2: N, T, W, R, S', ( SELECT id FROM day_patterns WHERE NAME = 'dp2' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp1' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp2' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp2' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp2' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp1' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp2' ) );
-- units
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('um1', 'um1', 'quantity', 3600, 'meter', '', 'none', false, 'um1 meter unit', -999999999, 999999999, 'reject_all');
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('ug2', 'ug2', 'quantity', 3600, 'unit', '', 'all', false, 'ug2 graphic unit', -999999999, 999999999, 'reject_all');
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('ug3', 'ug3', 'quantity', 3600, 'unit', '', 'all', false, 'ug3 graphic unit', -999999999, 999999999, 'reject_all');
-- conversions
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'um1' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug2' ), false, 'um1 -> ug2' );
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug2' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug3' ), true, 'ug2 <-> ug3' );
-- conversion segments
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'um1' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug2' ), NULL, 10, 0, '-infinity', '2020-06-03', 'segment 1 slope 10 um1 -> ug2' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'um1' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug2' ), (select id from week_patterns where name = 'w1'), 0, 0, '2020-06-03', '2020-06-07', 'segment 2 week 1 um1 <-> ug2' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'um1' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug2' ), null, 20, 0, '2020-06-07', '2020-06-16', 'segment 3 slope 20 um1 -> ug2' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'um1' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug2' ), null, 30, 0, '2020-06-16', 'infinity', 'segment 4 slope 30 um1 -> ug2' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug2' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug3' ), NULL, 40, 0, '-infinity', '2020-06-04', 'segment 1 slope 40 ug2 <-> ug3' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug2' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug3' ), NULL, 50, 0, '2020-06-04', '2020-06-10', 'segment 2 slope 50 ug2 <-> ug3' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug2' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug3' ), null, 60, 0, '2020-06-10', '2020-06-17', 'segment 3 slope 60 ug2 <-> ug3' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug2' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug3' ), null, 70, 0, '2020-06-17', 'infinity', 'segment 4 slope 70 ug2 <-> ug3' );
-- Week 2: need to do week 1 first
-- day pattern
insert into day_patterns values (DEFAULT, 'dp3', 'for ds13, ds17');
-- day segments
insert into day_segments values (DEFAULT, ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), 0, 12, 13, 0, 'd13 for dp3 0-12 slope 13');
insert into day_segments values (DEFAULT, ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), 12, 24, 17, 0, 'd17 for dp3 12-24 slope 17');
--- week pattern
insert into week_patterns values (DEFAULT, 'w2', 'dp3: all days', ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ), ( SELECT id FROM day_patterns WHERE NAME = 'dp3' ) );
-- units
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('ug4', 'ug4', 'quantity', 3600, 'unit', '', 'all', false, 'ug4 graphic unit', -999999999, 999999999, 'reject_all');
-- conversions
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug3' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug4' ), true, 'ug3 <-> ug4' );
-- conversion segments
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug3' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug4' ), NULL, 80, 0, '-infinity', '2020-06-06', 'segment 1 slope 80 ug3 <-> ug4' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug3' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug4' ), (select id from week_patterns where name = 'w2'), 0, 0, '2020-06-06', '2020-06-17', 'segment 2 week 2 ug3 <-> ug4' );
INSERT INTO CONVERSION_SEGMENTS VALUES ( ( SELECT id FROM units WHERE NAME = 'ug3' ), ( SELECT ID FROM UNITS WHERE NAME = 'ug4' ), null, 90, 0, '2020-06-17', 'infinity', 'segment 3 slope 90 ug3 <-> ug4' );-- meter: Not be formally needed but then can add readings when want.
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('m1', null, false, true, 'other', DEFAULT, DEFAULT, 'm1', 'meter 1', DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'um1' ), null, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);- This SQL was used to do the overall conversions.
- It is okay to only do w1 without w2 or just w2 if you add in unit ug3. Obviously the results will differ.
- It was also used without any patterns by using the conversion web page to set a conversion segment to no pattern and set the slope/intercept. In this case the days & weeks are not needed but they don't cause an issue being in the DB.
- Another variant was to remove some conversion segments from a week but this makes changes the result. The first test was only one non-pattern segment, then with a pattern, then two segments, then simple cases with chaining of conversion, etc.
- This was for short-term testing of newer time-vary work where patterns not there so manually inserting into conversions/cik/cik_vary so can see results.
These have "a" at the front of names so they show up early in the OED menus.
If you update cik_vary (and maybe cik) then the values inserted will be lost and you will not see what is desired.
Note that flow are the same where you simpley replace quantity -> flow everywhere.
- Quantity
- aumReadingsQuantity1: meter unit used for the test readings
- aumExpectQuantity1: meter unit for holding the expected values
- augQuantityTest1: the graphic unit to test TV conversions
These may not be strictly needed but nice to have. They should match the cik/cik_vary conversions to have them align.
- Quantity
- aumReadingsQuantity1 -> augQuantityTest1: holds the conversion for graphing the test readings in the graphic unit. This will be time_varying.
- aumExpectQuantity1 -> augQuantityTest1: holds the conversion for graphing the expected values in a graphic unit. This is a simple unit conversion across all time.
- Quantity
- aReadingsQuantity 1: meter used for the test readings
- aExpectHourlyQuantity 1: meter used for holding the expected Hourly values
- aExpectDailyQuantity 1: meter used for holding the expected Daily values
-- see data: see above/other examples for doing this.
select * from readings where meter_id = ( select id from meters where name = 'aReadingsQuantity 1' );
select * from readings where meter_id = ( select id from meters where name = 'aExpectHourlyQuantity 1' );
select * from readings where meter_id = ( select id from meters where name = 'aExpectDailyQuantity 1' );
select * from meter_daily_readings_unit where meter_id = ( select id from meters where name = 'aReadingsQuantity 1' );
select * from meter_hourly_readings_unit where meter_id = ( select id from meters where name = 'aExpectHourlyQuantity 1' );
select * from meter_hourly_readings_unit where meter_id = ( select id from meters where name = 'aExpectDailyQuantity 1' );
select * from meter_daily_readings_unit_cagg where meter_id = ( select id from meters where name = 'aReadingsQuantity 1' );
select * from meter_hourly_readings_unit_cagg where meter_id = ( select id from meters where name = 'aExpectHourlyQuantity 1' ) order by bucket;
select * from meter_hourly_readings_unit_cagg where meter_id = ( select id from meters where name = 'aExpectDailyQuantity 1' ) order by bucket;
-- Remove data
delete from readings where meter_id in ( select id from meters where name like 'aReadings%' or name like 'aExpect%' and default_graphic_unit in ( select id from units where name like 'aug%' ) );
delete from meters where name like 'aReadings%' or name like 'aExpect%' and default_graphic_unit in ( select id from units where name like 'aug%' );
delete from conversions where source_id in ( select id from units where name like 'aum%' ) and destination_id in ( select id from units where name like 'aug%' );
delete from cik where source_id in ( select id from units where name like 'aum%' ) and destination_id in ( select id from units where name like 'aug%' );
delete from cik_vary where source_id in ( select id from units where name like 'aum%' ) and destination_id in ( select id from units where name like 'aug%' );
delete from units where name like 'aug%' or name like 'aum%';
-- Insert test data
-- units
-- Quantity
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('aumReadingsQuantity1', 'aumReadingsQuantity1', 'quantity', 3600, 'meter', '', 'none', false, '', -999999999, 999999999, 'reject_all');
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('aumExpectQuantity1', 'aumExpectQuantity1', 'quantity', 3600, 'meter', '', 'none', false, '', -999999999, 999999999, 'reject_all');
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('augQuantityTest1', 'augQuantityTest1', 'quantity', 3600, 'unit', '', 'all', false, '', -999999999, 999999999, 'reject_all');
-- Flow
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('aumReadingsFlow1', 'aumReadingsFlow1', 'flow', 3600, 'meter', '', 'none', false, '', -999999999, 999999999, 'reject_all');
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('aumExpectFlow1', 'aumExpectFlow1', 'flow', 3600, 'meter', '', 'none', false, '', -999999999, 999999999, 'reject_all');
INSERT INTO units(name, identifier, unit_represent, sec_in_rate, type_of_unit, suffix, displayable, preferred_display, note, min_val, max_val, disable_checks) VALUES ('augFlowTest1', 'augFlowTest1', 'flow', 3600, 'unit', '', 'all', false, '', -999999999, 999999999, 'reject_all');
-- conversions: not formally needed but adding so can see in UI since easy & does not normally change with different tests.
-- Quantity
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'aumReadingsQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), false, '' );
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), false, '' );
-- Flow
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'aumReadingsFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), false, '' );
INSERT INTO CONVERSIONS VALUES ( ( SELECT id FROM units WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), false, '' );
-- conversion segments: not formally needed since ci_vary is set so not doing
-- cik
-- Quantity
INSERT INTO cik VALUES ( ( SELECT id FROM units WHERE NAME = 'aumReadingsQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ) );
INSERT INTO cik VALUES ( ( SELECT id FROM units WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ) );
-- Flow
INSERT INTO cik VALUES ( ( SELECT id FROM units WHERE NAME = 'aumReadingsFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ) );
INSERT INTO cik VALUES ( ( SELECT id FROM units WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ) );
-- cik_vary
-- For the test readings to graph
-- Quantity
-- Should be before data so use weird slope
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '-infinity', '2022-08-18 00:00:00', -99, 0);
-- time-varying for segments desired
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-08-18 00:00:00', '2022-08-20 00:00:00', 1, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-08-20 00:00:00', '2022-09-01 00:00:00', 2, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-09-01 00:00:00', '2022-09-01 09:00:00', 3, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-09-01 09:00:00', '2022-09-15 00:00:00', 4, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-09-15 00:00:00', '2022-10-01 00:00:00', 5, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-10-01 00:00:00', '2022-10-15 00:00:00', 6, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-10-15 00:00:00', '2022-11-01 00:00:00', 7, 0);
-- Should be after data so use weird slope
insert into cik_vary values( ( select id from units where name = 'aumReadingsQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '2022-11-01 00:00:00', 'infinity', -999, 0);
-- For the expected to graph. The is a unit conversion since it is already the desired value.
insert into cik_vary values( ( select id from units where name = 'aumExpectQuantity1' ), ( select id from units where name = 'augQuantityTest1' ), '-infinity', 'infinity', 1, 0);
-- Flow
-- Should be before data so use weird slope
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '-infinity', '2022-08-18 00:00:00', -99, 0);
-- time-varying for segments desired
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-08-18 00:00:00', '2022-08-20 00:00:00', 1, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-08-20 00:00:00', '2022-09-01 00:00:00', 2, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-09-01 00:00:00', '2022-09-01 09:00:00', 3, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-09-01 09:00:00', '2022-09-15 00:00:00', 4, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-09-15 00:00:00', '2022-10-01 00:00:00', 5, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-10-01 00:00:00', '2022-10-15 00:00:00', 6, 0);
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-10-15 00:00:00', '2022-11-01 00:00:00', 7, 0);
-- Should be after data so use weird slope
insert into cik_vary values( ( select id from units where name = 'aumReadingsFlow1' ), ( select id from units where name = 'augFlowTest1' ), '2022-11-01 00:00:00', 'infinity', -999, 0);
-- For the expected to graph. The is a unit conversion since it is already the desired value.
insert into cik_vary values( ( select id from units where name = 'aumExpectFlow1' ), ( select id from units where name = 'augFlowTest1' ), '-infinity', 'infinity', 1, 0);
-- Meters: only need to do once
-- Quantity
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aReadingsQuantity 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aReadingsQuantity 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumReadingsQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectHourlyQuantity 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectHourlyQuantity 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectHourlyQuantityMin 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectHourlyQuantityMin 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectHourlyQuantityMax 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectHourlyQuantityMax 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectDailyQuantity 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectDailyQuantity 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectDailyQuantityMin 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectDailyQuantityMin 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectDailyQuantityMax 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectDailyQuantityMax 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectQuantity1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augQuantityTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
-- Flow
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aReadingsFlow 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aReadingsFlow 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumReadingsFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectHourlyFlow 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectHourlyFlow 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectHourlyFlowMin 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectHourlyFlowMin 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectHourlyFlowMax 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectHourlyFlowMax 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectDailyFlow 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectDailyFlow 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectDailyFlowMin 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectDailyFlowMin 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error, disable_checks) VALUES ('aExpectDailyFlowMax 1', null, false, true, 'other', DEFAULT, DEFAULT, 'aExpectDailyFlowMax 1', DEFAULT, DEFAULT, false, false, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, ( SELECT ID FROM UNITS WHERE NAME = 'aumExpectFlow1' ), ( SELECT ID FROM UNITS WHERE NAME = 'augFlowTest1' ), DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT);The above segments match what was put into the spreadsheet "expect TV.ods". Then do:
- Run above SQL to create DB items.
- create CVS files to test the data. They come from "expect TV.ods".
- readingsTest1.csv: The values from the Input section for min or reading or max, start time, end time were placed into a CSV (in that order for first three columns) for the readings CSV.
- For Hourly (60 min/reading), the readings are in K11:K1810. For Daily (1440 min/reading), the readings are in K11:K85. These are put in column A of the CSV. The start/end times are the same ranges but in columns M,N, i.e., M11:N1810 for hourly. The min/max values are also in the same range but column J/L.
- Make sure For graphing? is true in spreadsheet.
- Create as many of these expected files as you want. Note you must set graphing to true in the spreadsheet to get the same values.
- readingsTest1.csv: has the 75 days of 15 minute readings for all tests. It will be loaded into multiple meters.
- expectedDailyQuantityTest1.csv: for daily data of a quantity.
- expectedDailyQuantityMinTest1.csv: for daily data of a quantity.
- ... Also Hourly instead of Daily, Max instead of Min, Flow for Quantity.
- Create as many of these expected files as you want. Note you must set graphing to true in the spreadsheet to get the same values.
- For flow, change Quantity data? in spreadsheet to false but the rest is the same where change naming to flow.
- Then these curl commands were run in a standard terminal (not the OED Docker container) where it is in the directory with the CSV files just created to upload the readings:
- Only need one Result meter since can change the range to see either Hourly or Daily. An alternative is to change the meter frequency so it thinks there are fewer points so returns hourly not daily for longer ranges of time.
- Quantity curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aReadingsQuantity 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@readingsTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectHourlyQuantity 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectHourlyQuantityTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectHourlyQuantityMin 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectHourlyQuantityMinTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectHourlyQuantityMax 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectHourlyQuantityMaxTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectDailyQuantity 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectDailyQuantityTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectDailyQuantityMin 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectDailyQuantityMinTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectDailyQuantityMax 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectDailyQuantityMaxTest1.csv'
- Flow curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aReadingsFlow 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@readingsTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectHourlyFlow 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectHourlyFlowTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectHourlyFlowMin 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectHourlyFlowMinTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectHourlyFlowMax 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectHourlyFlowMaxTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectDailyFlow 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectDailyFlowTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectDailyFlowMin 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectDailyFlowMinTest1.csv' curl http://localhost:3000/api/csv/readings -X POST -F 'meterName=aExpectDailyFlowMax 1' -F 'gzip=no' -F 'email=test' -F 'password=password' -F 'csvfile=@expectDailyFlowMaxTest1.csv'
- Only need one Result meter since can change the range to see either Hourly or Daily. An alternative is to change the meter frequency so it thinks there are fewer points so returns hourly not daily for longer ranges of time.
- If things go well then graphing those two meters with the augQuantityTest1 unit will be the same.
-- disable trigger: can see if PGAdmin if look at properties of the trigger.
ALTER TABLE readings DISABLE TRIGGER trg_readings_update_hourly_hypertable;
-- enable trigger
ALTER TABLE readings ENABLE TRIGGER trg_readings_update_hourly_hypertable;If you insert the standard test data and don't have other items in the DB that you manually added then you should get this when you look at cik_vary (select (select name from units where id = source_id), (select name from units where id = destination_id), * from cik_vary order by source_id, destination_id; ):
| source | destination | source_id | destination_id | start_time | end_time | slope | intercept |
|---|---|---|---|---|---|---|---|
| Electric_Utility | BTU | 211 | 206 | -infinity | infinity | 3412.142 | 0 |
| Electric_Utility | m³ gas | 211 | 207 | -infinity | infinity | 0.09315147659999999 | 0 |
| Electric_Utility | kWh | 211 | 209 | -infinity | infinity | 1 | 0 |
| Electric_Utility | US dollar | 211 | 217 | -infinity | infinity | 0.115 | 0 |
| Electric_Utility | MJ | 211 | 222 | -infinity | infinity | 3.6 | 0 |
| Electric_Utility | 100 w bulb | 211 | 224 | -infinity | infinity | 1 | 0 |
| Electric_Utility | euro | 211 | 226 | -infinity | infinity | 0.1012 | 0 |
| Electric_Utility | kg of CO₂ | 329 | 349 | -infinity | infinity | 0.709 | 0 |
| Electric_Utility | metric ton of CO₂ | 329 | 350 | -infinity | infinity | 0.000709 | 0 |
| Natural_Gas_M3 | BTU | 215 | 206 | -infinity | infinity | 36630.03663003663 | 0 |
| Natural_Gas_M3 | m³ gas | 215 | 207 | -infinity | infinity | 1 | 0 |
| Natural_Gas_M3 | kWh | 215 | 209 | -infinity | infinity | 10.73520288136796 | 0 |
| Natural_Gas_M3 | US dollar | 215 | 217 | -infinity | infinity | 0.25 | 0 |
| Natural_Gas_M3 | MJ | 215 | 222 | -infinity | infinity | 38.64673037292465 | 0 |
| Natural_Gas_M3 | 100 w bulb | 215 | 224 | -infinity | infinity | 10.73520288136796 | 0 |
| Natural_Gas_M3 | euro | 215 | 226 | -infinity | infinity | 0.22 | 0 |
| Water_Gallon | liter | 216 | 205 | -infinity | infinity | 3.7853996378886707 | 0 |
| Water_Gallon | gallon | 216 | 212 | -infinity | infinity | 1 | 0 |
| Temperature_Fahrenheit | Fahrenheit | 219 | 208 | -infinity | infinity | 1 | 0 |
| Temperature_Fahrenheit | Celsius | 219 | 214 | -infinity | infinity | 0.5555555555555556 | -17.77777777777778 |
| Electric_kW | kW | 221 | 220 | -infinity | infinity | 1 | 0 |
| Natural_Gas_BTU | BTU | 223 | 206 | -infinity | infinity | 1 | 0 |
| Natural_Gas_BTU | m³ gas | 223 | 207 | -infinity | infinity | 2.73e-05 | 0 |
| Natural_Gas_BTU | kWh | 223 | 209 | -infinity | infinity | 0.0002930710386613453 | 0 |
| Natural_Gas_BTU | US dollar | 223 | 217 | -infinity | infinity | 2.954545454545455e-06 | 0 |
| Natural_Gas_BTU | MJ | 223 | 222 | -infinity | infinity | 0.0010550557391808431 | 0 |
| Natural_Gas_BTU | 100 w bulb | 223 | 224 | -infinity | infinity | 0.0002930710386613453 | 0 |
| Natural_Gas_BTU | euro | 223 | 226 | -infinity | infinity | 2.6e-06 | 0 |
| Natural_Gas_BTU | kg of CO₂ | 339 | 349 | -infinity | infinity | 5.29e-05 | 0 |
| Natural_Gas_BTU | metric ton of CO₂ | 339 | 350 | -infinity | infinity | 5.29e-08 | 0 |
| Natural_Gas_Dollar | US dollar | 225 | 217 | -infinity | infinity | 1 | 0 |
| Natural_Gas_Dollar | euro | 225 | 226 | -infinity | infinity | 0.88 | 0 |
| Trash | kg | 229 | 210 | -infinity | infinity | 1 | 0 |
| Trash | metric ton | 229 | 213 | -infinity | infinity | 0.001 | 0 |
| Trash | kg of CO₂ | 345 | 349 | -infinity | infinity | 3.24e-06 | 0 |
| Trash | metric ton of CO₂ | 345 | 350 | -infinity | infinity | 3.24e-09 | 0 |
| Water_Gallon_Per_Minute | gallon per minute | 230 | 227 | -infinity | infinity | 1 | 0 |
| Water_Gallon_Per_Minute | liter per hour | 230 | 228 | -infinity | infinity | 227.12398 | 0 |