Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix composite measures should be correctly exported to CSV #309

Merged
merged 8 commits into from
Jun 15, 2023

Conversation

tdislay
Copy link
Contributor

@tdislay tdislay commented Jun 11, 2023

What does this PR do ?

Composite measures (measures with multiple properties, which can be objects) are now correctly exported. Before, only the property with the name equal to the measure type was exported (see the issue below).
Fixes #308.

Other changes

  • Property "position" was moved to the top of the valueMappings for the position measurement. It helps with consistency (which means, we do not need to sort properties from the mappings to display in a logical order the columns in the csv export).

Boyscout

  • Ordering some imports
  • Corrected a misnamed test

Comment on lines +24 to +29
name: "ask:device-manager:model:measure:get";

payload: { type: string };

result: MeasureModelContent;
};
Copy link
Member

Choose a reason for hiding this comment

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

Nit-picking, why blank lines here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Idk, it was already done this way..
But I'm curious about it 🤔 ..

Comment on lines 278 to 280
const header = `${name}${
pathWithoutType !== "" ? `.${pathWithoutType}` : ""
}`;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const header = `${name}${
pathWithoutType !== "" ? `.${pathWithoutType}` : ""
}`;
const header = `${name}.${pathWithoutType}`;

This ternary condition seems to be useless.
Unless if you want to handle nullish value in this case you have an error and the better solution is to use nullish coalsing, like pathWithoutType ?? ''

Copy link
Contributor Author

@tdislay tdislay Jun 14, 2023

Choose a reason for hiding this comment

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

You're not entirely right, it was useful, but your comment made me rework this crap.

I've fixed it. I now use a simple regex to do what I wanted to do.
I will add a comment in this PR explaining what I did

@tdislay
Copy link
Contributor Author

tdislay commented Jun 14, 2023

Following my response to Seb's comment.

When I implemented this fix, I assumed that we should not repeat the type of a measure in the column header.
Normally the header of a measure should look like this (here I assume the measure's name !== measure's type in the decoder) :

temperatureInt.temperature, temperatureExt.temperature, accelerationSensor.acceleration.x, accelerationSensor.accuracy

What's actually going on is this:

temperatureInt, temperatureExt, accelerationSensor.x, accelerationSensor.accuracy

Do you guys, think this should not be this way ?

@tdislay tdislay force-pushed the fix/export-correctly-composite-measures branch from d63b92a to 7692786 Compare June 14, 2023 08:31
@tdislay tdislay merged commit 470c894 into 2-dev Jun 15, 2023
@tdislay tdislay deleted the fix/export-correctly-composite-measures branch June 15, 2023 07:58
sebtiz13 pushed a commit that referenced this pull request Jul 24, 2023
* refactor: add acceleration measure to the DummyTemp Decoder

* fix: test name

* test: implement failing tests

* feat: add an ask event to retrieve the content of a measure

* feat: generate a measure column for each property of a measure

* fix: position needs to be the first property for consistency purposes

* fix: failing test

* refactor: more proper way of computing header string

---------

Co-authored-by: Théo Dislay <tdislay@kuzzle.io>
github-actions bot pushed a commit that referenced this pull request Aug 14, 2023
# [2.3.0](v2.2.8...v2.3.0) (2023-08-14)

### Bug Fixes

* composite measures should be correctly exported to CSV ([#309](#309)) ([487c1e8](487c1e8))
* **docs:** wrong arguments in models' getDevice request ([#310](#310)) ([028c65c](028c65c))

### Features

* **assetGroups:** add assetGroups roles ([b9d0fae](b9d0fae))
* **assetGroups:** add groups for assets ([#306](#306)) ([10de8b4](10de8b4))
* **assetGroups:** add lastUpdate on changes  ([#311](#311)) ([36a4575](36a4575))
* **semantic-release:** add semantic release support to device manager ([99b1683](99b1683))
github-actions bot pushed a commit that referenced this pull request Aug 14, 2023
# [2.3.0](v2.2.8...v2.3.0) (2023-08-14)

### Bug Fixes

* composite measures should be correctly exported to CSV ([#309](#309)) ([487c1e8](487c1e8))
* **docs:** wrong arguments in models' getDevice request ([#310](#310)) ([028c65c](028c65c))

### Features

* **assetGroups:** add assetGroups roles ([b9d0fae](b9d0fae))
* **assetGroups:** add groups for assets ([#306](#306)) ([10de8b4](10de8b4))
* **assetGroups:** add lastUpdate on changes  ([#311](#311)) ([36a4575](36a4575))
* **semantic-release:** add semantic release support to device manager ([99b1683](99b1683))
sebtiz13 pushed a commit that referenced this pull request Aug 14, 2023
# [2.3.0](v2.2.8...v2.3.0) (2023-08-14)

### Bug Fixes

* composite measures should be correctly exported to CSV ([#309](#309)) ([487c1e8](487c1e8))
* **docs:** wrong arguments in models' getDevice request ([#310](#310)) ([028c65c](028c65c))

### Features

* **assetGroups:** add assetGroups roles ([b9d0fae](b9d0fae))
* **assetGroups:** add groups for assets ([#306](#306)) ([10de8b4](10de8b4))
* **assetGroups:** add lastUpdate on changes  ([#311](#311)) ([36a4575](36a4575))
* **semantic-release:** add semantic release support to device manager ([99b1683](99b1683))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants