Skip to content

Conversation

tjsaunders
Copy link

Clearly open to suggestions, I would like to be able to change the block calculation to find the max rather than min for the Outgoing tariff block, but am interested in your input.

Thanks

Fix number of outputs and rename node for identifiability
semicolons and closed brackets
Ctrl+C the brackets, don't control X...
Renamed because no longer need identifiability
I fat finger removed the m from msg3
different Outgoing check because everything is coming back as agile
@tjsaunders
Copy link
Author

I should have added some evidence:
image
This is my test flow, it has one node for Agile and one for Outgoing. Feeding into InfluxDB.
image
The Grafana output showing the 2 datasets in the InfluxDB with the 2 sources.

octopus.js Outdated

msg.payload.results.forEach(function(item, index) {
msg3.payload.push([{ value_inc_vat : item.value_inc_vat,
if (APIurl.includes("OUTGOING")) {
Copy link
Owner

@borpin borpin Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the this.tariff == "OUTGOING" comparison?

Even better is remove the if, and just set the value of source dependent on the Tariff selected (removes repeated code).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this, but I think "this" doesn't refer to the node by this point in the function (and therefore this.tariff doesn't evaluate to anything)? The condition always evaluated to false. I couldn't think of a way to get the tariff value at that point in the code without just using the APIurl which I knew was there. I'm not massively familiar with js, so it may just be me not understanding.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the final 2 commits, the penultimate one was verifying what I thought was happening (both outputs swapped to Agile), and the final commit let them evaluate to different things.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this (and to be honest my JS is a little minimal) I wonder why I ever moved it from n.tariff to this.tariff. n.tariff should be fine to use throughout. Try that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this (and to be honest my JS is a little minimal) I wonder why I ever moved it from n.tariff to this.tariff. n.tariff should be fine to use throughout. Try that.

Would you prefer I change this.region as well, or just this.tariff?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my point. If you set a variable for source dependent on the tariff in use, you can use it without resorting to multiple 'if' statements and repeating code blocks.

@borpin
Copy link
Owner

borpin commented Aug 5, 2020

On looking for maximum, at line 103, there is an array of blocks, of length specified, that I then look for the min. It should be possible to look for a max block. Probably needs a radio button in the UI to select max or min, then return the blocks on that basis.

Will need some rewording of the variables to make sense.

@borpin
Copy link
Owner

borpin commented Aug 5, 2020

I have also realised the min_block_start value should not be added to output1 as if there is more than one block it is just the last block. I'll raise an issue to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants