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
fix rubocop issues
Jonas Jabari7145af752be5
diff --git a/app/components/work_packages/activities_tab/journals/index_component.rb b/app/components/work_packages/activities_tab/journals/index_component.rbindex 67a199e280a..35535014b0a 100644--- a/app/components/work_packages/activities_tab/journals/index_component.rb+++ b/app/components/work_packages/activities_tab/journals/index_component.rb@@ -64,43 +64,35 @@ module WorkPackagesenddef base_journals- # Get journals with eager loading- journals = API::V3::Activities::ActivityEagerLoadingWrapper.wrap(+ combine_and_sort_records(fetch_journals, fetch_revisions)+ end++ def fetch_journals+ API::V3::Activities::ActivityEagerLoadingWrapper.wrap(work_package.journals- .includes(- :user,- :customizable_journals,- :attachable_journals,- :storable_journals,- :notifications- )+ .includes(:user, :customizable_journals, :attachable_journals, :storable_journals, :notifications).reorder(version: journal_sorting).with_sequence_version)+ end- # Get associated revisions- revisions = work_package.changesets.includes(:user, :repository)+ def fetch_revisions+ work_package.changesets.includes(:user, :repository)+ end- # Combine and sort them by date- if journal_sorting_desc?- (journals + revisions).sort_by do |record|- timestamp = if record.is_a?(API::V3::Activities::ActivityEagerLoadingWrapper)- record.created_at&.to_i- elsif record.is_a?(Changeset)- record.committed_on.to_i- end- [-timestamp, -record.id]- end- else- (journals + revisions).sort_by do |record|- timestamp = if record.is_a?(API::V3::Activities::ActivityEagerLoadingWrapper)- record.created_at&.to_i- elsif record.is_a?(Changeset)- record.committed_on.to_i- end- [timestamp, record.id]- end+ def combine_and_sort_records(journals, revisions)+ (journals + revisions).sort_by do |record|+ timestamp = record_timestamp(record)+ journal_sorting_desc? ? [-timestamp, -record.id] : [timestamp, record.id]+ end+ end++ def record_timestamp(record)+ if record.is_a?(API::V3::Activities::ActivityEagerLoadingWrapper)+ record.created_at&.to_i+ elsif record.is_a?(Changeset)+ record.committed_on.to_iendenddiff --git a/app/components/work_packages/activities_tab/journals/revision_component.rb b/app/components/work_packages/activities_tab/journals/revision_component.rbindex f2d6272bbe3..bd6b4c8bebe 100644--- a/app/components/work_packages/activities_tab/journals/revision_component.rb+++ b/app/components/work_packages/activities_tab/journals/revision_component.rb@@ -1,4 +1,34 @@-require 'sanitize'+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require "sanitize"module WorkPackagesmodule ActivitiesTab