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

Add CSV export option to zoomed in plots #4252

Merged
merged 9 commits into from
Jul 13, 2023
Merged

Add CSV export option to zoomed in plots #4252

merged 9 commits into from
Jul 13, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Jul 10, 2023

Demo

Screen.Recording.2023-07-12.at.11.24.55.AM.mov

Part of #4246

@julieg18 julieg18 added the product PR that affects product label Jul 10, 2023
@julieg18 julieg18 self-assigned this Jul 10, 2023
@julieg18 julieg18 marked this pull request as ready for review July 12, 2023 16:26
arr: Array<{ [key: string]: unknown }>
) => {
ensureFileSync(path)
const csv = await json2csv(arr)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be able to reuse this package for creating tsv files by adjusting the options.

Copy link
Member

Choose a reason for hiding this comment

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

Yes! let's please add the second option also. TSV is way simpler to use in a lot of cases.

(I would check if data needs to be sanitized in some way)

@julieg18 julieg18 marked this pull request as draft July 12, 2023 16:32
@julieg18 julieg18 marked this pull request as ready for review July 12, 2023 16:56
@julieg18 julieg18 requested a review from shcheklein July 12, 2023 16:56
extension/package.json Outdated Show resolved Hide resolved
} else {
await writeCsv(
filePath,
rawData as unknown as Array<{ [key: string]: unknown }>
Copy link
Member

Choose a reason for hiding this comment

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

[Q] How can the data types for the raw data be different depending on the type of export?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These types were actually just a bandaid so I could test exports. Will adjust the types!

@@ -227,7 +228,11 @@ export class PlotsModel extends ModelWithPersistence {
return selectedRevisions
}

public savePlotData(plotId: string, filePath: string) {
public async savePlotData(
Copy link
Member

Choose a reason for hiding this comment

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

[I] Rather than have a flag argument for savePlotData I would have different functions savePlotDataAsJson, etc. Even if the write functions are passed to a base function.

Copy link
Member

Choose a reason for hiding this comment

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

that would then give different messages from the webview which could have different telemetry events and tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took off the flag argument and used separate functions instead!

@@ -344,19 +346,35 @@ export class WebviewMessages {
return this.plots.getCustomPlots() || null
}

private async exportPlotData(plotId: string) {
const file = await showSaveDialog(Uri.file('data.json'), { JSON: ['json'] })
private async exportPlotDataAsJson(plotId: string) {
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

this.plots.savePlotData(plotId, file.path)
void this.plots.savePlotDataAsJson(file.path, plotId)
}

Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

@codeclimate
Copy link

codeclimate bot commented Jul 13, 2023

Code Climate has analyzed commit 6e9158d and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 98.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.1% (0.0% change).

View more on Code Climate.

@julieg18 julieg18 merged commit ca0414c into main Jul 13, 2023
3 checks passed
@julieg18 julieg18 deleted the add-csv-export branch July 13, 2023 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants