Skip to content

Extract methods from proposals seeds#12005

Merged
alecslupu merged 15 commits intodevelopfrom
refactor/seeds-proposals-cleanup
Nov 18, 2023
Merged

Extract methods from proposals seeds#12005
alecslupu merged 15 commits intodevelopfrom
refactor/seeds-proposals-cleanup

Conversation

@andreslucena
Copy link
Copy Markdown
Member

🎩 What? Why?

Refactors the proposals seeds to individual methods.

There are lots of good reasons why doing this (lower the complexity of these classes, make it more readable, etc). But my main reason is to provide an API to be able to work on some issues that we need to have lots of contents (like #11874).

So, this API would be like:

seed = Decidim::Proposals::Seeds.new(participatory_space:)
seed.create_proposal!(component:)

Apart from that I fixed some sampling that was too complex, and I've removed the Endorsements from here (as we're doing it at #11996). Another difference is the use the n and m variables. Apart from not wanting to pass it as a parameter, I prefer to have some randomness there, so we don't have always the same contents in all the spaces (like always only one rejected proposal, another approved, another evaluating, and so on)

For making the review process easier, I tried to do granular commits, so I recommend reviewing this on a commit by commit basis.

Testing

Regenerating the development_app database should have different kind of proposals (almost the same as before):

$ bin/rails db:drop db:create db:migrate db:seed

You can play with the methods like this too:

participatory_space = Decidim::ParticipatoryProcess.first
component = participatory_space.components.find_by(manifest_name: :proposals)
seed = Decidim::Proposals::Seeds.new(participatory_space:)
800.times.each { seed.create_proposal!(component:) }

♥️ Thank you!

github-actions[bot]
github-actions bot previously approved these changes Nov 15, 2023
github-actions[bot]
github-actions bot previously approved these changes Nov 16, 2023
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks ok, the seeds are doing what they are supposed to do, but there are some small changes that needs to be done before.

Also, make it consistent with the `organization` method

Co-authored-by: Alexandru Emil Lupu <contact@alecslupu.ro>
github-actions[bot]
github-actions bot previously approved these changes Nov 18, 2023
github-actions[bot]
github-actions bot previously approved these changes Nov 18, 2023
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants