OpenFn / lightning

OpenFn/Lightning ⚡️ is the newest version of the OpenFn DPG and provides a web UI to visually manage complex workflow automation projects.
https://openfn.github.io/lightning/
GNU Lesser General Public License v3.0
130 stars 36 forks source link

Refactor create_project, create_user, register_user #2084

Open taylordowns2000 opened 6 months ago

taylordowns2000 commented 6 months ago

There are a bunch of account-related features that need unpicking. Lightning.Projects.create_project was recently extended and now includes some emailing behaviour. Some unwanted side effects appeared, and we think that it's a good time to refactor these contexts and functions.

Ideally, we'd always have the ability to create a project or create a user without sending emails. If we want to introduce more complex business logic like that introduced here we should consider a higher level function (like a service) that does a number of things.

By changing the deep create_project function like in the commit above, we risk modifying a lot of application behaviour.

taylordowns2000 commented 6 months ago

For discussion later, I spoke about this with @midigofrank and we found the spot that changed.

Before this commit, create_project only created projects. The pattern in use was:

def some_save_button do
  create_project
  send_email
end

and that's exactly what I'd like to see. In the commit above create_project got modified so that it really is create_project_and_send_email, and the other parts of the app that call create_project are now trying to send emails. (It's not many I don't think, but it's still a significant change in what that deep "crud-sounding" function does.)

image

For what it's worth, the only impacted places here are setup_utils and the load tests.