Multiple selection for inclusion-validated task attributes
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with TasksHelper#parameter_field in the engine's app/helpers, where inclusion-validated attributes become a single select, and the task attribute handling that casts run arguments. Decide between a shipped array attribute type and a per-task declaration, then add tests covering rendering and casting of the submitted array with its hidden blank value. Done means a multiple select stores and round-trips a list of values through the run form.
Written by the indexing model from the issue text.
Description
When a task attribute has an inclusion validator, the run form renders it as a single <select> (TasksHelper#parameter_field). There is no way to let the person running the task pick several values from the same list.
Our case is a task that takes a logical dump of a chosen set of database tables. The options come from a proc (inclusion: { in: ->(_) { ActiveRecord::Base.connection.tables.sort } }), and the task needs one or more of them. Without a multiple select, the choice is between a free-text, comma-separated field (no list to pick from, typos only caught by validation) and overriding the gem's helper.
Most of the pieces already work with arrays:
- Rails' inclusion validator checks arrays element by element;
- run arguments are stored as JSON, so an array round-trips.
What is missing:
- Rendering:
parameter_fieldwould need to passmultiple: truetoselectfor such attributes. - Casting: ActiveModel has no array attribute type, so the attribute needs a type that casts the submitted array and drops the hidden blank value Rails adds to multiple selects.
Our workaround on 2.17.0 is a small ActiveModel::Type::Value subclass for string lists, plus a module prepended to MaintenanceTasks::TasksHelper that renders attributes of that type as select(..., multiple: true). It works, but it depends on a private helper's signature.
Would you accept built-in support? Two shapes come to mind:
- the gem ships an array attribute type (e.g.
attribute :tables, MaintenanceTasks::Types::StringList.new), andparameter_fieldrenders a multiple select when an inclusion-validated attribute uses it; - or a declaration on the task, e.g.
multiple_select :tables.
Happy to open a PR with whichever approach you prefer, including tests.
- Dominant language
- Ruby
- Stars
- 1.3k
- Forks
- 115
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/maintenance_tasks
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Shopify/maintenance_tasks#1607 ·
-
Weekly CI run failedOpen
Difficulty 3/5 Half a day Newbie friendliness 30/100
Shopify/maintenance_tasks#1609 ·
All issues in Shopify/maintenance_tasks
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TarteelAI/quranic-universal-library#1111 ·
Maintainers usually reply within 1 day
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every commandPossibly taken @k4kratik claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sachincool/cruft#4 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
riscv/riscv-unified-db#2859 ·
Maintainers usually reply within 2 days
-
agent-driven deployment documentation future releases nice to have
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
changesets
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openstreetmap/openstreetmap-website#7629 · 1 comment ·
Maintainers usually reply within 1 day