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

Export data to CSV/XSLX weekly #304

Open
rapee opened this issue Oct 3, 2017 · 9 comments
Open

Export data to CSV/XSLX weekly #304

rapee opened this issue Oct 3, 2017 · 9 comments

Comments

@rapee
Copy link
Member

rapee commented Oct 3, 2017

Export pins as CSV or XSLX

Input:

  • Start - end date range
  • Assigned department (optional)
  • Assigned user (optional)

Output:

Tabular data with these columns:

  • Pin Detail
  • Status
  • Reported Date
  • Close Date (if any)
  • Assigned Department
  • Assigned User
  • Category (in Thai and English)
  • Tag
@p16i
Copy link
Contributor

p16i commented Oct 3, 2017

Should it be a command line script?

@jochasinga
Copy link

jochasinga commented Oct 9, 2017

Seems to me like a cron job in another container might be fitting. Maybe a pure service that takes any data object (in JSON perhaps) and response with a CSV file transparently that gets run by a cron job weekly.

formatData(obj) -> csv

If no one is on this, I'd like to give it a first take.

Also, are we limited to using Javascript, provided if docker orchestrates isolated services?

@p16i
Copy link
Contributor

p16i commented Oct 10, 2017

Actually, I have another idea. Maybe we can create a new route for this purpose. For example,

URL : ./export/pins?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD&department=[all|...]&format=[json|xml|csv]

I guess they plan to use it from frontend. Meaning that, the user will select date range and the frontend will redirect to this url with parameters and return data with corresponding content-type. We might also need to check whether the user have an access to data of the department.

@jochasinga
Copy link

@heytitle I see. Why weekly then? That sounded like something that's not user-facing.

@rapee
Copy link
Member Author

rapee commented Oct 10, 2017

@jochasinga You're right, the weekly part is unnecessary. It will be handled on frontend.

I agree with @heytitle about making a new route for this.

@jochasinga
Copy link

So basically the route send a GET request with relevant query params or payload to the database, retrieve the data and do the parsing to CSV or whatever format on the frontend.

@p16i
Copy link
Contributor

p16i commented Oct 12, 2017

I think the workflow will look like this.
gitscout-image-from-clipboard-1

What do you think?
cc: @jochasinga @rapee @parnurzeal @supasate

@jochasinga
Copy link

@heytitle you mean the api server responds with Content-Type: 'text/csv' and does the parsing in the back end while the UI returns a promise and display a download element when response is ready. Looks good.

@p16i
Copy link
Contributor

p16i commented Oct 20, 2017

@jochasinga actually, what I meant by download dialog is the one from the browser which can be called in 2 ways to do that

  1. using download attribute of <a>. For example,
<a href="<path>/<to>/<api>?query=.." download="filename.csv">Download</a>
  1. add Content-Disposition: attachment; filename="filename.csv" header when returning the data. I've tested found that using Content-Type only would't force browser to show the save dialog. See : https://stackoverflow.com/questions/20039533/how-can-i-force-a-save-as-dialog

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

No branches or pull requests

4 participants