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

Use xlsx instead of kotlin-csv #70

Closed
wants to merge 9 commits into from

Conversation

sohyun-ku
Copy link
Contributor

#69

I used xlsx instead of vue-json-csv. Becuz I want to create a csv file after fetching the snapshot data using callback.

@sohyun-ku sohyun-ku requested review from a team and junoyoon as code owners May 8, 2023 03:03
@github-actions
Copy link

github-actions bot commented May 8, 2023

Scavenger Test Results

155 files  155 suites   36s ⏱️
254 tests 242 ✔️ 12 💤 0
256 runs  244 ✔️ 12 💤 0

Results for commit 90c8f8a.

♻️ This comment has been updated with latest results.

@taeyeon-Kim
Copy link
Contributor

taeyeon-Kim commented May 9, 2023

  • We don't use kotlin-csv anymore, so please delete it as well.
  • Is the reason we can't use vue-json-csv is because we can't handle the download event on click event after calling the api?

@@ -85,6 +85,8 @@ import SnapshotForm from "./SnapshotForm.vue";
import Momnet from "moment";
import {useStore} from "../util/store";
import {ElMessageBox, ElNotification} from "element-plus";
import * as Xlsx from 'xlsx'
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, the delimiter was tab. Is this the same in xsx?

Copy link
Contributor Author

@sohyun-ku sohyun-ku May 10, 2023

Choose a reason for hiding this comment

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

In xlsx, the default field separator delimiter is ,

https://www.npmjs.com/package/xlsx#delimiter-separated-output

@sohyun-ku
Copy link
Contributor Author

@taeyeon-Kim

Is the reason we can't use vue-json-csv is because we can't handle the download event on click event after calling the api?

If we use vue-json-csv, we can use like below.

<download-csv
    :data   = "json_data">
    Download Data
    <img src="download_icon.png">
</download-csv>

But...There was a problem in the process of receiving data asynchronously when a click event occurred.
There may be several workarounds, but none of the features are explicitly provided by the package. (Belphemur/vue-json-csv#175)
The reason why I used xlsx is that I wanted to implement a function that asynchronously call data when a click event occurs and creates an excel file with a callback.

@sohyun-ku sohyun-ku force-pushed the feature/apply-xlsx-instead-of-kotlin-csv branch from 588c26e to 20e912c Compare May 10, 2023 02:54
@@ -105,31 +97,12 @@ class SnapshotController(
)
}

@GetMapping("/customers/{customerId}/snapshot/{snapshotId}/export", produces = ["text/csv"])
@GetMapping("/customers/{customerId}/snapshots/{snapshotId}/export")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also rename the methods across the board?
It seems like it's now an API to get all snapshot nodes rather than 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.

Fixed in d6d4a4e

@sohyun-ku sohyun-ku force-pushed the feature/apply-xlsx-instead-of-kotlin-csv branch from d6d4a4e to de84c20 Compare May 16, 2023 10:41
@sohyun-ku
Copy link
Contributor Author

sohyun-ku commented May 16, 2023

There is no body size limit for HTTP responses, but added paging because it can take a long time to parse large size JSON data in the browser.
The execution time based on 10000 rows in my local env is within 1s.

@sohyun-ku sohyun-ku force-pushed the feature/apply-xlsx-instead-of-kotlin-csv branch from 146dd31 to f2b4e9f Compare May 17, 2023 02:56
@@ -30,7 +30,9 @@
"splitpanes": "^3.1.5",
"vue": "^3.2.41",
"vue-i18n": "^9.2.2",
"vue-router": "^4.1.6"
"vue-loading-overlay": "^6.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@sohyun-ku sohyun-ku self-assigned this May 17, 2023
private val sql: SnapshotNodeSql = super.sqls(::SnapshotNodeSql)

fun findAllExportSnapshotNode(
fun selectAllExportSnapshotNode(
Copy link
Collaborator

Choose a reason for hiding this comment

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

we use find 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.

fixed in 90c8f8a

}

utils.book_append_sheet(workBook, workSheet);
writeFile(workBook, `snapshot_${id}.csv`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@sohyun-ku

Could u explain why xlsx should be created in fe layer? what was your intention here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened this issue #69.
In my opinion... it has the advantage of not handling IO on the server and doesn't require direct control of FE's DOM.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is really necessary.
This fix blocks the way directly download excel using curl. Moreover, it always need to use the browser.
Instead of this... what about adding excel download beside of csv?

Copy link
Contributor

Choose a reason for hiding this comment

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

@junoyoon
I hadn't considered downloading excel via curl. 😭
I think that's a good way to go,
@sohyun-ku please comment as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't considered using curl too..haha..

what about adding excel download beside of csv?

Before I did this PR, there was already excel download feature, what does this mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

@junoyoon Please check out sohyun`s comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@sohyun-ku @taeyeon-Kim
Sorry for late response. I was too busy.. :-(

It was csv export feature not excel.
And csv is created in server side.
So it's callable using cli

I think we should make it server side job (not fe).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@junoyoon @taeyeon-Kim

thanks for explaining :)
I didn't think someone can use cli when using csv export feature...
We have already a csv export feature on the server side before this PR.
So I'll close this PR.

@sohyun-ku sohyun-ku force-pushed the feature/apply-xlsx-instead-of-kotlin-csv branch from efe32b6 to 90c8f8a Compare May 24, 2023 01:41
@sohyun-ku sohyun-ku requested a review from junoyoon June 7, 2023 01:26
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.

3 participants