So, without any sample data, here is something to get you started...
flow (use CTRL+I
to import)
[{"id":"c36db0db5407437e","type":"function","z":"49f61d916c8f6022","name":"dummy data (replace with http request)","func":"const todayDate = new Date(new Date().setHours(0, 0, 0, 0))\nconst tomorrowDate = new Date(new Date(Date.now() + 24 * 60 * 60 * 1000).setHours(0, 0, 0, 0));\nconst today = todayDate.toLocaleDateString('fr-CA')\nconst tomorrow = tomorrowDate.toLocaleDateString('fr-CA')\nconst data = []\nfor (let i = 0; i < 48; i++) {\n const h = i % 24\n const time = (h + '').padStart(2,'0') + ':' + ((h % 2) ? '30' : '00')\n data.push({\n PointOfConnectionCode: \"test_data\",\n TradingDate: i > 23 ? tomorrow : today,\n TradingPeriodNumber: i + 1,\n RunDateTime: time,\n DollarsPerMegawattHour: +((Math.random() * 10) + 36).toFixed(2)\n })\n \n}\nmsg.payload = data\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1270,"y":480,"wires":[["4f8cdbb0e76d6de5","cce565d66a05bf1d"]]},{"id":"fb8adcc002d8d25e","type":"inject","z":"49f61d916c8f6022","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1020,"y":480,"wires":[["c36db0db5407437e"]]},{"id":"4f8cdbb0e76d6de5","type":"debug","z":"49f61d916c8f6022","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1520,"y":480,"wires":[]},{"id":"cce565d66a05bf1d","type":"function","z":"49f61d916c8f6022","name":"get best times","func":"const data = msg.payload\nconst min = data.reduce(function (prev, curr) {\n return prev.DollarsPerMegawattHour < curr.DollarsPerMegawattHour ? prev : curr\n})\nconst max = data.reduce(function (prev, curr) {\n return prev.DollarsPerMegawattHour > curr.DollarsPerMegawattHour ? prev : curr\n})\n\nmsg.payload = {min, max}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1340,"y":540,"wires":[["322cff4cb23f2849"]]},{"id":"322cff4cb23f2849","type":"debug","z":"49f61d916c8f6022","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1500,"y":540,"wires":[]}]
Which given data like this...
[
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 1,
"RunDateTime": "00:00",
"DollarsPerMegawattHour": 37.88
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 2,
"RunDateTime": "01:30",
"DollarsPerMegawattHour": 36.76
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 3,
"RunDateTime": "02:00",
"DollarsPerMegawattHour": 39.5
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 4,
"RunDateTime": "03:30",
"DollarsPerMegawattHour": 37.97
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 5,
"RunDateTime": "04:00",
"DollarsPerMegawattHour": 43.25
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 6,
"RunDateTime": "05:30",
"DollarsPerMegawattHour": 36.92
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 7,
"RunDateTime": "06:00",
"DollarsPerMegawattHour": 42.61
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 8,
"RunDateTime": "07:30",
"DollarsPerMegawattHour": 37.4
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 9,
"RunDateTime": "08:00",
"DollarsPerMegawattHour": 37.07
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 10,
"RunDateTime": "09:30",
"DollarsPerMegawattHour": 43.31
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 11,
"RunDateTime": "10:00",
"DollarsPerMegawattHour": 43.02
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 12,
"RunDateTime": "11:30",
"DollarsPerMegawattHour": 38.59
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 13,
"RunDateTime": "12:00",
"DollarsPerMegawattHour": 38.49
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 14,
"RunDateTime": "13:30",
"DollarsPerMegawattHour": 36.64
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 15,
"RunDateTime": "14:00",
"DollarsPerMegawattHour": 36.51
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 16,
"RunDateTime": "15:30",
"DollarsPerMegawattHour": 36.81
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 17,
"RunDateTime": "16:00",
"DollarsPerMegawattHour": 40.22
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 18,
"RunDateTime": "17:30",
"DollarsPerMegawattHour": 40.96
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 19,
"RunDateTime": "18:00",
"DollarsPerMegawattHour": 44.69
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 20,
"RunDateTime": "19:30",
"DollarsPerMegawattHour": 41.5
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 21,
"RunDateTime": "20:00",
"DollarsPerMegawattHour": 44.37
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 22,
"RunDateTime": "21:30",
"DollarsPerMegawattHour": 38.79
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 23,
"RunDateTime": "22:00",
"DollarsPerMegawattHour": 36.49
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-07-31",
"TradingPeriodNumber": 24,
"RunDateTime": "23:30",
"DollarsPerMegawattHour": 42.54
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 25,
"RunDateTime": "00:00",
"DollarsPerMegawattHour": 43.48
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 26,
"RunDateTime": "01:30",
"DollarsPerMegawattHour": 37.42
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 27,
"RunDateTime": "02:00",
"DollarsPerMegawattHour": 40.74
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 28,
"RunDateTime": "03:30",
"DollarsPerMegawattHour": 42.15
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 29,
"RunDateTime": "04:00",
"DollarsPerMegawattHour": 44.88
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 30,
"RunDateTime": "05:30",
"DollarsPerMegawattHour": 43.72
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 31,
"RunDateTime": "06:00",
"DollarsPerMegawattHour": 38.61
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 32,
"RunDateTime": "07:30",
"DollarsPerMegawattHour": 44.18
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 33,
"RunDateTime": "08:00",
"DollarsPerMegawattHour": 40.82
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 34,
"RunDateTime": "09:30",
"DollarsPerMegawattHour": 45.23
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 35,
"RunDateTime": "10:00",
"DollarsPerMegawattHour": 43.82
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 36,
"RunDateTime": "11:30",
"DollarsPerMegawattHour": 39.03
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 37,
"RunDateTime": "12:00",
"DollarsPerMegawattHour": 43.94
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 38,
"RunDateTime": "13:30",
"DollarsPerMegawattHour": 37.11
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 39,
"RunDateTime": "14:00",
"DollarsPerMegawattHour": 38.82
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 40,
"RunDateTime": "15:30",
"DollarsPerMegawattHour": 44.18
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 41,
"RunDateTime": "16:00",
"DollarsPerMegawattHour": 39.98
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 42,
"RunDateTime": "17:30",
"DollarsPerMegawattHour": 36.33
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 43,
"RunDateTime": "18:00",
"DollarsPerMegawattHour": 39.97
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 44,
"RunDateTime": "19:30",
"DollarsPerMegawattHour": 43.75
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 45,
"RunDateTime": "20:00",
"DollarsPerMegawattHour": 44.54
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 46,
"RunDateTime": "21:30",
"DollarsPerMegawattHour": 42.12
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 47,
"RunDateTime": "22:00",
"DollarsPerMegawattHour": 45.27
},
{
"PointOfConnectionCode": "test_data",
"TradingDate": "2022-08-01",
"TradingPeriodNumber": 48,
"RunDateTime": "23:30",
"DollarsPerMegawattHour": 44.08
}
]
will return this...