Project

General

Profile

Actions

Feature #40449

closed

Add updated_on and updated_by fields to Issues API journal response

Added by Thomas Hoffmann 8 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
REST API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

We would like to synchronize the redmine issues with our internal system via API.
For this purpose, we fetch the issues with:

curl -H "X-Redmine-API-Key: secret" "https://domain.com/issues/58.json?include=children%2Cattachments%2Crelations%2Cchangesets%2Cjournals%2Cwatchers%2Callowed_statuses" -vv

The journal is returned but we can't determine, which entry changed.
Therefore, it would be helpful to not only have the created_on but also the updated_on field.

The file app/views/issues/show.api.rsb needs an extra line at line 61:

...
api.created_on journal.created_on
api.updated_on journal.updated_on
api.private_notes journal.private_notes
...


Files

40449.patch (1.36 KB) 40449.patch Go MAEDA, 2024-05-24 10:33

Related issues

Related to Redmine - Feature #31505: Mark edited journal notes as "Edited"ClosedGo MAEDA

Actions
Related to Redmine - Feature #40450: Add API-Request for fetching Journals which has changed since a certain date/timeNew

Actions
Actions #1

Updated by Thomas Hoffmann 8 months ago

I added a PR if this makes life easier:
https://github.com/redmine/redmine/pull/149

Please move issue to Patch or Feature, it's not a defect.

Actions #2

Updated by Go MAEDA 8 months ago

  • Tracker changed from Defect to Patch
  • Affected version deleted (5.1.2)

Thank you for suggesting this improvement.

I believe it would be beneficial to include not only updated_on but also updated_by.

diff --git a/app/views/issues/show.api.rsb b/app/views/issues/show.api.rsb
index 6f23ca4b4..6ca8b2d10 100644
--- a/app/views/issues/show.api.rsb
+++ b/app/views/issues/show.api.rsb
@@ -59,6 +59,8 @@ api.issue do
         api.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
         api.notes journal.notes
         api.created_on journal.created_on
+        api.updated_on journal.updated_on
+        api.updated_by(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
         api.private_notes journal.private_notes
         api.array :details do
           journal.visible_details.each do |detail|
Actions #3

Updated by Go MAEDA 8 months ago

  • Related to Feature #31505: Mark edited journal notes as "Edited" added
Actions #4

Updated by Thomas Hoffmann 8 months ago

api.updated_by looks the same as api.user
So it might not add additional information (?)

Actions #5

Updated by Go MAEDA 8 months ago

Thomas Hoffmann wrote in #note-4:

api.updated_by looks the same as api.user
So it might not add additional information (?)

Sorry, the patch in #note-2 is wrong. It should be as follows. Journal#updated_by stores information who last updated the journal.

diff --git a/app/views/issues/show.api.rsb b/app/views/issues/show.api.rsb
index 6f23ca4b4..2c341163a 100644
--- a/app/views/issues/show.api.rsb
+++ b/app/views/issues/show.api.rsb
@@ -59,6 +59,8 @@ api.issue do
         api.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
         api.notes journal.notes
         api.created_on journal.created_on
+        api.updated_on journal.updated_on
+        api.updated_by(:id => journal.updated_by.id, :name => journal.updated_by.name) unless journal.updated_by.nil?
         api.private_notes journal.private_notes
         api.array :details do
           journal.visible_details.each do |detail|
Actions #6

Updated by Thomas Hoffmann 8 months ago

Looks fine to me now.
Would be nice to have the patch in one of the upcoming releases.
Thanks for your help :)

Actions #7

Updated by Holger Just 8 months ago

  • Related to Feature #40450: Add API-Request for fetching Journals which has changed since a certain date/time added
Actions #8

Updated by Go MAEDA 6 months ago

Here is a patch that implements the feature.

Actions #9

Updated by Go MAEDA 6 months ago

  • Target version changed from Candidate for next major release to 6.0.0

Setting the target version to 6.0.0.

Actions #10

Updated by Go MAEDA 6 months ago

  • Tracker changed from Patch to Feature
  • Subject changed from Add updated_on field in the issue journal to Add updated_on and updated_by fields to Issues API journal response
  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch in r22846. Thank you for your contribution.

Actions

Also available in: Atom PDF