Feature #2176
Updated by Tom Clegg over 10 years ago
Generalize the special case in jobs.create.
Add optional @find_or_create@ flag to @create@ method. If set:
* If @filters@ parameter is provided, look up objects using those filters.
** If exactly one result is found, return that.
** If no results are found, create a new object as usual.
** If >1 results are found, return an error.
* If @filters@ parameter is not provided, look up objects using the provided resource_attrs as a @where@ parameter, and proceed as above.
Jobs.create should be rearranged to use the generic mechanism.
* Move @no_reuse@ (and other params that aren't actually resource attributes) out of @resource_attrs@, e.g., @params[:job][:minimum_script_version]=X@ should move to something like @params[:filters]=[['script_version','>=',X]]@ and JobsController should override @apply_where_limit_order_params@ to use find_commit_range when @>=@ and @<=@ filters are used with the @script_version@ attribute.
* Implement @exclude_script_versions=X@ as @params[:filters]=[['script_version','not in',X]]@ (adding a @"not in"@ operator should be trivial)
* Implement the range logic so the client can do commit range lookups itself using @list@, not just implicitly via @create@