Skip to content

Snaked case parameters don't work #11

@pklapperich

Description

@pklapperich

All over in the code are blocks like:

const splitStr = orderStr.split('_');
      	const id = splitStr[1];
      	const attribute = splitStr[2];
      	const events = graphData[id][attribute];

This breaks if your device has a parameter like production_energy_today. Most likely creating an "order string" like this is just a bad idea. Instead of concatenating multiple values into a string, why not just pass multiple values around or even a JSON object?

But I think in many cases a brittle fix might be something like const attribute = splitStr.slice(2).join('_') which will re-construct the original attribute name. This works so long as "attribute" was the last item in the order string (eg it'll work for attribute_38_consumption_energy_today but won't work for things like attribute_consumption_energy_today_38)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions