alleyinteractive / wp-bulk-task

A library to assist with running performant bulk tasks against WordPress database objects.
GNU General Public License v2.0
13 stars 0 forks source link

Feature: Add support for CSV files #19

Closed renatonascalves closed 5 months ago

renatonascalves commented 5 months ago

Description

Imagine creating a CLI command to perform migrations from a CSV file into a site. Currently, the bulk task does't support this scenario.

Ideally, the run method accepts an optional $object_type argument. When csv is supplied as the arg. The first argument would also accept a CSV file, with its params.

Use Case

A CLI command to perform migrations from a CSV file into a site. The CLI will benefit from all the benefits of the Bulk_Task task.

kevinfodness commented 5 months ago

You're saying rather than having the source data come from the WP database, have it come from a CSV file?

renatonascalves commented 5 months ago

Correct. As an option.

I currently have a few CLI commands that accept a CSV file, and perform migrations to the rows and noticed we are losing a lot of the goodies from this library. Besides forcing one to duplicate a lot of functionality.

I'm thinking of something similar to this: https://github.com/alleyinteractive/wp-bulk-task/blob/193f03008a17ce5609798be5b4b8eaf073f85bbd/src/class-bulk-task.php#L236

A custom one that handles CSV rows.

kevinfodness commented 5 months ago

That makes sense, and then the callback, instead of passing a WP_Post object, passes in the row extracted from the CSV, and implementers are responsible for doing what they want with that row. Good suggestion!

renatonascalves commented 5 months ago

Exactly!