Project

General

Profile

Actions

Feature #33418

closed

Bulk addition of related issues

Added by Dmitry Makurin almost 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

Sometimes you need to add a lot of relations to an issue and it's getting really hard when there're 50 or more relations.

The patch provides bulk create for relations. Fill an input field with ids (delimited with comma) and press form's button.

example


Files


Related issues

Related to Redmine - Feature #29272: Create several relations at the same time via Issue Relations APINew

Actions
Related to Redmine - Defect #35039: API create issue relation method returns undefined method `split' when issue id is sent as integerClosedGo MAEDA

Actions
Related to Redmine - Defect #35655: Create duplicated follows relations fails with 500 internal errorClosedMarius BĂLTEANU

Actions
Actions #1

Updated by Robert Korulczyk almost 4 years ago

+1. I miss this feature so much...

Actions #2

Updated by Go MAEDA almost 4 years ago

  • Target version set to Candidate for next major release
Actions #3

Updated by Go MAEDA almost 4 years ago

  • Related to Feature #29272: Create several relations at the same time via Issue Relations API added
Actions #4

Updated by Go MAEDA over 3 years ago

  • Category set to Issues
Actions #5

Updated by Go MAEDA over 3 years ago

I tried out the patch and found it really nice.

The only one small issue of the patch is that issue auto-complete feature does not work. But I think we can resolve it by using Tribute.js which is used for inline auto complete feature (#31989).

Actions #6

Updated by Go MAEDA over 3 years ago

Go MAEDA wrote:

The only one small issue of the patch is that issue auto-complete feature does not work. But I think we can resolve it by using Tribute.js which is used for inline auto complete feature (#31989).

I realized that implementing the feature with Tribute.js is not so easy because the auto-complete should be triggered without typing a preceding "#" in the related issues section.

Now I think it is OK even if the feature does not support auto-comple for multiple issue ids because it is a trivial matter compared to the usefulness of this feature.

Actions #7

Updated by Marius BĂLTEANU over 3 years ago

  • Assignee set to Marius BĂLTEANU
Actions #8

Updated by Marius BĂLTEANU over 3 years ago

Dmitry, thanks for posting the patch. I find this feature really useful.

Regarding your proposed solution, I don't think that it's a good ideea to remove the validation from the model because it will allow setting a non visible issue if you by-pass the controller (from a plugin, for example).

I'm attaching two patches:

1. 0001-Rework-patch-from-33418.patch
Based on the existing patch, but keeping the validation in the model and also fixes some edge-case bugs (for ex: no error if you press Add without typing the issue id).

2. 0002-Allow-issue-relation-autocomplete-to-select-multiple
Adds a new JS autocomplete function that allows searching for multiple values. If the solution is good enough, I'll add a system test for it.

Actions #9

Updated by Go MAEDA over 3 years ago

Marius, thank you for improving the patch. I tried out the patches #33418#note-8 and found they are really nice.

Marius BALTEANU wrote:

2. 0002-Allow-issue-relation-autocomplete-to-select-multiple
Adds a new JS autocomplete function that allows searching for multiple values. If the solution is good enough, I'll add a system test for it.

I didn't feel strange compared to the autocomplete in Redmine 4.1.0.

Actions #10

Updated by Marius BĂLTEANU over 3 years ago

  • File deleted (0002-Allow-issue-relation-autocomplete-to-select-multiple.patch)
Actions #11

Updated by Marius BĂLTEANU over 3 years ago

Updated the second patch to include a test.

Let's discuss this for 4.2.0.

Actions #12

Updated by Go MAEDA over 3 years ago

  • Tracker changed from Patch to Feature
  • Subject changed from Issue relation bulk create to Bulk addition of related issues
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for improving Redmine.

Actions #13

Updated by Go MAEDA over 3 years ago

  • Related to deleted (Feature #29272: Create several relations at the same time via Issue Relations API)
Actions #14

Updated by Go MAEDA over 3 years ago

  • Has duplicate Feature #29272: Create several relations at the same time via Issue Relations API added
Actions #15

Updated by Go MAEDA over 3 years ago

  • Has duplicate deleted (Feature #29272: Create several relations at the same time via Issue Relations API)
Actions #16

Updated by Go MAEDA over 3 years ago

  • Related to Feature #29272: Create several relations at the same time via Issue Relations API added
Actions #17

Updated by Marius BĂLTEANU over 3 years ago

I'm reopening this to discuss about the API part which is not implemented 100% correctly.

1. Request:
Currently, for bulk addition of related issues, the request should contains the ids as comma-delimited string, please see the below example (param issue_to_id):

post(
  '/issues/2/relations.xml',
  :params => {:relation => {:issue_to_id => "7, 8", :relation_type => 'relates'}}
)

I think we should accept also an array of ids:

post(
  '/issues/2/relations.xml',
  :params => {:relation => {:issue_to_id => [7, 8], :relation_type => 'relates'}}
)

The attached patch allows this.

2. Response:
Currently, the response contain only the latest relation added:

{
  "relation": {
    "id": 107,
    "issue_id": 2,
    "issue_to_id": 8,
    "relation_type": "relates",
    "delay": null
  }
}

I think the response should contain all the created relations:

{
  "relations": [
    {
      "id": 114,
      "issue_id": 2,
      "issue_to_id": 7,
      "relation_type": "relates",
      "delay": null
    },
    {
      "id": 115,
      "issue_id": 2,
      "issue_to_id": 8,
      "relation_type": "relates",
      "delay": null
    }
  ]
}

but I'm not sure how to handle the case when the response contain both successfully created relations and non-successfully relations. From what I know, we don't have this kind of mixed API response in Redmine.

I see two options:
1. We change the current implementation to be transactional. In this way, we reject the entire request if an error occurs.
2. We respond with succes if at least one relation was created successfully and we append the error messages to the response:

{
  "relations": [
    {
      "id": 114,
      "issue_id": 2,
      "issue_to_id": 7,
      "relation_type": "relates",
      "delay": null
    },
    {
      "id": 115,
      "issue_id": 2,
      "issue_to_id": 8,
      "relation_type": "relates",
      "delay": null
    }
  ],
  "errors": [
    "Related issue has already been taken: #3",
  ]
}

Any feedback is welcome!

Actions #18

Updated by Marius BĂLTEANU about 3 years ago

  • Assignee set to Marius BĂLTEANU
Actions #19

Updated by Marius BĂLTEANU about 3 years ago

  • Status changed from Reopened to Closed

We will postpone the fixes for API to another version.

Actions #20

Updated by Alex Last about 3 years ago

hi everyone! I am the owner of redmine-java-api project (https://github.com/taskadapter/redmine-java-api).
I get a server error with Redmine 4.2.0 when trying to create a relation with the request body that previously worked for Redmine 3.x:

{"relation"=>{"issue_to_id"=>576, "relation_type"=>"relates"}, "issue_id"=>"575"}

the error is:

NoMethodError (undefined method `split' for 576:Integer):

because issue_to_id is now expected to be a string with commas, instead of a number.

is this a permanent change or just an experiment? it would be too expensive to maintain compatibility for multiple redmine versions in the java library.

Actions #21

Updated by Alex Last about 3 years ago

side note - if Redmine REST API supported returning some "server info", the clients could at least choose what json blob to send (for redmine 3.x, 4.x, etc). but since this is not supported, there is no good way to support several redmine REST formats in clients.

Actions #22

Updated by Marius BĂLTEANU about 3 years ago

  • Related to Defect #35039: API create issue relation method returns undefined method `split' when issue id is sent as integer added
Actions #23

Updated by Marius BĂLTEANU about 3 years ago

Thanks Alex Last for reporting this issue. It's a defect, I've created #35039 to track this, the fix will be available in 4.2.1.

Actions #24

Updated by Marius BĂLTEANU over 2 years ago

  • Related to Defect #35655: Create duplicated follows relations fails with 500 internal error added
Actions

Also available in: Atom PDF