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

New Issues import from CSV? #360

Open
GelLiNN opened this issue Aug 17, 2018 · 5 comments
Open

New Issues import from CSV? #360

GelLiNN opened this issue Aug 17, 2018 · 5 comments

Comments

@GelLiNN
Copy link

GelLiNN commented Aug 17, 2018

I would like to either request this as a new feature or help build it. For my company's use case we need to be able to import CSV and create new issues from that with new custom fields as they appear in the CSV.

The new issues could go through the internal API, and be created in the exact same way that the webform submits its request, except that it has new custom fields in the db created for however many there are in the CSV.

The CSV will definitely have description, name, etc already populated

@Alanaktion
Copy link
Owner

This is mostly doable, although automatically adding custom fields could be a bit tricky, since a lot of the issue information is loaded from the issue_detail view instead of directly from the issue table, so that view would need to be updated every time a column was added to the issue table. That would likely break upgrades to new versions of the database if they change that view.

Early on, there was going to be a system for managing custom issue fields, but it was removed before it was fully implemented since it wasn't something my team needed internally. For now, it would be fairly simple to implement a CSV import that matched only existing issue fields, though that does somewhat limit where you could import data from with a 1:1 match.

@GelLiNN
Copy link
Author

GelLiNN commented Aug 21, 2018

Alright I'll bite, how would I go about making a CSV import that trimmed any extra fields and only made issues with the current supported fields?

@Alanaktion
Copy link
Owner

That mostly comes down to how often you'll be using it and how well-integrated you want it to be. If you only need to do a one-time import from another system, something as simple as using MySQL's LOAD DATA INFILE directly into the issue table from a correctly-formatted CSV could be enough.

Something a bit more robust, but still fairly easy to implement would be a PHP file run from the command line, including the cron/base.php file and using the Issue model in a loop with PHP's fgetcsv to read the data from the CSV file.

If it's something you'll be using frequently, and would like to make intuitive for non-developers, an ideal implementation would be using PHP's fgetcsv on an uploaded file though the Administration panel. This would require:

  1. Creating a new controller to handle the file upload
  2. Creating a view to either show as its own page, or as a section within another page to show the file selection to upload the CSV
  3. A function that reads the uploaded CSV file using fgetcsv and creates the issues using the Issue model, similar to the command-line option

Something like this could be implemented directly in the core code and submitted as a pull request, or done through a plugin (though that would limit where the upload UI could go). It definitely seems like something that could be a useful feature for a lot of people, so it'd probably be a good case for a core feature.

@GelLiNN
Copy link
Author

GelLiNN commented Aug 21, 2018

I like the idea of it being a plugin, because non admins are going to be using it to upload issues from their own CSV files. There would just be a form that allows you to select the file, then click upload and have the php script do the trimming, then when done it displays "25 new issues created" in a dialog box.
Does that sound like something you could build pretty quick?

Or should I try to build it

@GelLiNN
Copy link
Author

GelLiNN commented Aug 21, 2018

I'm also wondering about how to set up the email notifications. I have a sparkpost mail server I use to send automatic notifications from another laravel site I'm running, and would like to integrate that same mail server to send all of the notification emails from my domain email on phproject too.

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

2 participants