OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
introduce updatedAt property on activites and use it to track changes
ulfertsecc168b62cbb
diff --git a/app/services/journals/create_service.rb b/app/services/journals/create_service.rbindex aced0db093e..aa061b049ce 100644--- a/app/services/journals/create_service.rb+++ b/app/services/journals/create_service.rb@@ -108,9 +108,9 @@ module Journals# (i.e. when determining the latest state of the journable and when getting the current version number).## The second CTE (`changes`) determines whether a change as occurred so that a new journal needs to be created. The next CTE,- # that will insert new data, will only do so if the changes CTE returns an entry. The only exception to this check is that- # if a note is provided, a journal will be created regardless of whether any changes are detected. To determine whether a- # change is worthy of being journalized, the current and the latest journalized state are compared in three aspects:+ # that will insert new data, will only do so if the changes CTE returns an entry. The only two exceptions to this check is that+ # if a note is provided or a predecessor is replaced, a journal will be created regardless of whether any changes are detected.+ # To determine whether a change is worthy of being journalized, the current and the latest journalized state are compared in three aspects:# * the journable's table columns are compared to the columns in the journable's journal data table# (e.g. work_package_journals for WorkPackages). Only columns that exist in the journable's journal data table are considered# (and some columns like the primary key `id` is ignored). Therefore, to add an attribute to be journalized, it needs to@@ -121,8 +121,8 @@ module Journals# When comparing text based values, newlines are normalized as otherwise users having a different OS might change a text value# without intending to.#- # Only if a change has been identified (or if a note is present) is a journal inserted by the third CTE (`insert_journal`).- # Its creation timestamp will be updated_at value of the journable as this is the logical creation time. If a note is present,+ # Only if a change has been identified (or if a note/predecessor is present) is a journal inserted by the third CTE (`insert_journal`).+ # Its creation timestamp will be the updated_at value of the journable as this is the logical creation time. If a note is present,# however, the current time is taken as it signifies an action in itself and there might not be a change at all. In such a# case, the journable will later on receive the creation date of the journal as its updated_at value. The update timestamp of# a journable and the creation date of its most recent journal should always be in sync.@@ -147,7 +147,7 @@ module Journals), changes AS (#{select_changed_sql}), insert_data AS (- #{insert_data_sql(notes)}+ #{insert_data_sql(notes, predecessor)}), inserted_journal AS (#{update_or_insert_journal_sql(predecessor, notes)}), insert_attachable AS (@@ -236,8 +236,8 @@ module Journalsdata_type: journable.class.journal_class.name)end- def insert_data_sql(notes)- condition = if notes.blank?+ def insert_data_sql(notes, predecessor)+ condition = if notes.blank? && predecessor.nil?"AND EXISTS (SELECT * FROM changes)"else""diff --git a/docs/api/apiv3/components/schemas/activity_model.yml b/docs/api/apiv3/components/schemas/activity_model.ymlindex 9e387f467ff..cd771d269ef 100644--- a/docs/api/apiv3/components/schemas/activity_model.yml+++ b/docs/api/apiv3/components/schemas/activity_model.yml@@ -29,6 +29,11 @@ properties:format: date-timedescription: Time of creationreadOnly: true+ updatedAt:+ type: string+ format: date-time+ description: Time of update+ readOnly: trueexample:_type: Activity::Comment_links:@@ -51,4 +56,5 @@ example:raw: Lorem ipsum dolor sit amet.html: "<p>Lorem ipsum dolor sit amet.</p>"createdAt: '2014-05-21T08:51:20Z'+ updatedAt: '2014-05-21T09:14:02Z'version: 31diff --git a/docs/api/apiv3/components/schemas/work_package_activities_model.yml b/docs/api/apiv3/components/schemas/work_package_activities_model.ymlindex f0faba5a5be..14cdb4376b7 100644--- a/docs/api/apiv3/components/schemas/work_package_activities_model.yml+++ b/docs/api/apiv3/components/schemas/work_package_activities_model.yml@@ -25,6 +25,7 @@ example:raw: Lorem ipsum dolor sit amet.html: "<p>Lorem ipsum dolor sit amet.</p>"createdAt: '2014-05-21T08:51:20Z'+ updatedAt: '2014-05-21T09:14:02Z'version: 1- _type: Activity_links:@@ -40,5 +41,6 @@ example:format: markdownraw: Lorem ipsum dolor sit amet.html: "<p>Lorem ipsum dolor sit amet.</p>"- createdAt: '2014-05-21T08:51:22Z'+ createdAt: '2014-05-21T09:51:22Z'+ updatedAt: '2014-05-21T10:14:02Z'version: 2diff --git a/docs/api/apiv3/paths/activity.yml b/docs/api/apiv3/paths/activity.ymlindex a288961ee64..f39807d3434 100644--- a/docs/api/apiv3/paths/activity.yml+++ b/docs/api/apiv3/paths/activity.yml@@ -33,6 +33,7 @@ get:html: "<p>Lorem ipsum dolor sit amet.</p>"raw: Lorem ipsum dolor sit amet.createdAt: '2014-05-21T08:51:20Z'+ updatedAt: '2014-05-21T09:14:02Z'details:- format: markdownhtml: "<p>Lorem ipsum dolor sit amet.</p>"@@ -81,6 +82,7 @@ patch:html: "<p>Lorem ipsum dolor sit amet.</p>"raw: Lorem ipsum dolor sit amet.createdAt: '2014-05-21T08:51:20Z'+ updatedAt: '2014-05-21T09:14:02Z'details:- format: markdownhtml: "<p>Lorem ipsum dolor sit amet.</p>"diff --git a/docs/api/apiv3/paths/work_package_activities.yml b/docs/api/apiv3/paths/work_package_activities.ymlindex fb1f5ba978d..fa2e00e67be 100644--- a/docs/api/apiv3/paths/work_package_activities.yml+++ b/docs/api/apiv3/paths/work_package_activities.yml@@ -31,6 +31,7 @@ get:html: "<p>Lorem ipsum dolor sit amet.</p>"raw: Lorem ipsum dolor sit amet.createdAt: '2014-05-21T08:51:20Z'+ updatedAt: '2014-05-21T09:14:02Z'details: []id: 1version: 1@@ -46,7 +47,8 @@ get:format: markdownhtml: "<p>Lorem ipsum dolor sit amet.</p>"raw: Lorem ipsum dolor sit amet.- createdAt: '2014-05-21T08:51:22Z'+ createdAt: '2014-05-21T09:51:22Z'+ updatedAt: '2014-05-21T10:14:02Z'details: []id: 2version: 2diff --git a/docs/api/apiv3/tags/activities.yml b/docs/api/apiv3/tags/activities.ymlindex 2b4a0a31751..b9d7878e42d 100644--- a/docs/api/apiv3/tags/activities.yml+++ b/docs/api/apiv3/tags/activities.yml@@ -9,6 +9,7 @@ description: |-| comment | | Formattable | | READ / WRITE || details | | Array of Formattable | | READ || createdAt | Time of creation | DateTime | | READ |+ | updatedAt | Time of update | DateTime | | READ |Activity can be either _type `Activity` or _type `Activity::Comment`.name: Activitiesdiff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.tsindex 2786766b2e3..f39df688d64 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts@@ -51,13 +51,17 @@ export class ActivityEntryInfo {}public get identifier() {- return `${this.href}-${this.version}`;+ return `${this.href}-${this.version}-${this.updatedAt}`;}public get version() {return this.activity.version;}+ public get updatedAt() {+ return this.activity.updatedAt;+ }+public isInitial(forceReverse = false) {let activityNo = this.number(forceReverse);diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.tsindex bcc7ca371c7..06b3733c509 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.component.ts@@ -43,7 +43,7 @@ export class NewestActivityOnOverviewComponent extends ActivityPanelBaseControllpublic latestActivityInfo:ActivityEntryInfo[] = [];- public trackByHref = trackByProperty('identifier');+ public trackByIdentifier = trackByProperty('identifier');ngOnInit() {this.workPackageId = this.workPackage.id!;diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.htmlindex 662f4265507..260a835c526 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.html+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-on-overview.html@@ -1,7 +1,7 @@<work-package-comment [workPackage]="workPackage"><ng-template><div class='work-package-details-activities-list'>- <div *ngFor="let inf of latestActivityInfo; trackBy:trackByHref"+ <div *ngFor="let inf of latestActivityInfo; trackBy:trackByIdentifier"class="work-package-details-activities-activity"><activity-entry [workPackage]="workPackage"[activity]="inf.activity"diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.tsindex 9bf8da64775..64ef4bcbe8c 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.component.ts@@ -28,7 +28,7 @@import { Component } from '@angular/core';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';-import { trackByHrefAndProperty } from 'core-app/shared/helpers/angular/tracking-functions';+import { trackByProperty } from 'core-app/shared/helpers/angular/tracking-functions';import { ActivityPanelBaseController } from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller';@Component({@@ -40,7 +40,7 @@ export class WorkPackageActivityTabComponent extends ActivityPanelBaseControllerpublic tabName = this.I18n.t('js.work_packages.tabs.activity');- public trackByHref = trackByHrefAndProperty('version');+ public trackByIdentifier = trackByProperty('identifier');ngOnInit() {const { workPackageId } = this.uiRouterGlobals.params as unknown as { workPackageId:string };diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.htmlindex dc32983e554..b287d4b4877 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.html+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.html@@ -3,7 +3,7 @@<div class="detail-activity"><div class="work-package-details-activities-list"><div- *ngFor="let inf of visibleActivities; trackBy:trackByHref; let first = first"+ *ngFor="let inf of visibleActivities; trackBy:trackByIdentifier; let first = first"class="work-package-details-activities-activity"><h3diff --git a/lib/api/v3/activities/activity_representer.rb b/lib/api/v3/activities/activity_representer.rbindex c92d84c6f3c..048ff415967 100644--- a/lib/api/v3/activities/activity_representer.rb+++ b/lib/api/v3/activities/activity_representer.rb@@ -75,6 +75,7 @@ module APIproperty :version, render_nil: truedate_time_property :created_at+ date_time_property :updated_atdef _typeif represented.noop? || represented.notes.present?diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rbindex 1d07ea46fd9..d38480537bd 100644--- a/spec/features/work_packages/edit_work_package_spec.rb+++ b/spec/features/work_packages/edit_work_package_spec.rb@@ -159,6 +159,7 @@ describe 'edit work package',status: status2.name,version: version.name,category: category.name+wp_page.expect_activity_message("Status changed from #{status.name} to #{status2.name}")enddiff --git a/spec/lib/api/v3/activities/activity_representer_rendering_spec.rb b/spec/lib/api/v3/activities/activity_representer_rendering_spec.rbindex a411e3d5641..e5aa0f37db4 100644--- a/spec/lib/api/v3/activities/activity_representer_rendering_spec.rb+++ b/spec/lib/api/v3/activities/activity_representer_rendering_spec.rb@@ -100,6 +100,13 @@ describe ::API::V3::Activities::ActivityRepresenter, 'rendering' doendend+ describe 'updatedAt' do+ it_behaves_like 'has UTC ISO 8601 date and time' do+ let(:date) { journal.updated_at }+ let(:json_path) { 'updatedAt' }+ end+ end+describe 'version' doit_behaves_like 'property', :version dolet(:value) { journal.version }