Closed jagthedrummer closed 4 months ago
I did a little futzing with the core
repo (locally) to add a generator for PerformsImport
and then ran some tests to compare PerformsImport
with TargetsOneParent
.
First I generated a Widget
super scaffold:
rails g super_scaffold Widget Team name:text_field; rails db:migrate
rails db:migrate
Then I generated a PerformsImport
:
rails g super_scaffold:action_models:performs_import Import Widget Team
rails db:migrate
And I also generated a TargetsOneParent
:
rails g super_scaffold:action_models:targets_one_parent TargetedImport Widget Team
rails db:migrate
Now I have a couple of new options in the widget list:
Clicking on "Import" gets me to this screen which has some options around actually performing an import:
But clicking on "Targeted Import" gets me to this screen which doesn't offer any options:
So PerformsImport
seems to offer some built-in functionality that's missing with TargetsOneParent
. I'm guessing you could implement an import action via TargetsOneParent
but it seems like PerformsImport
offers some useful functionality.
OK, I also cracked open the code for the PerformsImport
and PerformsExport
base classes and they definitely implement features that aren't present in the Targets*
classes.
In fact PerformsImport
directly includes the TargetsOne
concern (not TargetsOneParent
) and PerformsExport
directly imports TargetsMany
. So they use the Targets*
building blocks and then implement functionality over the top of them.
I think we need to add generators and documentation for these two.
@jagthedrummer I remember these two not being fully documented, and since I didn't help to build them I didn't move forward with any documentation/further implementation.
I do remember however talking with Andrew about these briefly, and the use-case for them was mainly for importing/exporting CSVs, which is reflected in the system tests.
If it helps, I also worked on a fun PR for import actions which uses OpenAI to guess which CSV column most closely matches the database model in question.
I'm not entirely sure what other use-cases we have for these actions though.
Added generators here: https://github.com/bullet-train-co/bullet_train-core/pull/853
The
PerformsImport
andPerformsExport
actions aren't documented: https://bullettrain.co/docs/action-models#action-typesAnd it's currently impossible to generate either one.
But we occasionally get questions about them.
The description for
TargetsOneParent
(https://bullettrain.co/docs/action-models#targets-one-parent) sounds like it's intended to be used for import actions. And it seems like it would also work for export actions.Is it true that
PerformsImport
andPerformsExport
should be deprecated and removed in favor of a more generalTargetsOneParent
?