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
rubocop auto-amendments
Kabiru Mwenja338174f27efa
diff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.rb b/app/components/work_packages/activities_tab/journals/item_component/reactions.rbindex 2c35315dc30..8fd1605a5e1 100644--- a/app/components/work_packages/activities_tab/journals/item_component/reactions.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.rb@@ -60,19 +60,21 @@ module WorkPackagesmax_displayed_users_count = 5user_count = users.length- displayed_users = users.take(max_displayed_users_count).map { |u| u[:name] }+ displayed_users = users.take(max_displayed_users_count).pluck(:name)result = if user_count <= max_displayed_users_count- displayed_users.join(', ')- elsif user_count == max_displayed_users_count + 1- "#{displayed_users.join(', ')} #{I18n.t("reactions.and_n_others_singular", n: 1)}"- else- "#{displayed_users.join(', ')} #{I18n.t("reactions.and_n_others_plural", n: user_count - max_displayed_users_count)}"- end+ displayed_users.join(", ")+ elsif user_count == max_displayed_users_count + 1+ "#{displayed_users.join(', ')} #{I18n.t('reactions.and_n_others_singular', n: 1)}"+ else+ "#{displayed_users.join(', ')} #{I18n.t('reactions.and_n_others_plural',+ n: user_count - max_displayed_users_count)}"+ endresult += " "result += I18n.t("reactions.reacted_with", emoji_shortcode: EmojiReaction.shortcode(emoji))+ resultendendenddiff --git a/app/contracts/emoji_reactions/base_contract.rb b/app/contracts/emoji_reactions/base_contract.rbindex 821f801aa49..8a0658291d7 100644--- a/app/contracts/emoji_reactions/base_contract.rb+++ b/app/contracts/emoji_reactions/base_contract.rb@@ -54,7 +54,7 @@ module EmojiReactionsenddef validate_reactable_exists- errors.add :reactable, :error_not_found unless model.reactable.present?+ errors.add :reactable, :error_not_found if model.reactable.blank?enddef validate_emoji_typediff --git a/app/models/concerns/reactable.rb b/app/models/concerns/reactable.rbindex a6b658aa858..ef5eb26e433 100644--- a/app/models/concerns/reactable.rb+++ b/app/models/concerns/reactable.rb@@ -34,11 +34,11 @@ module Reactableenddef add_reaction(user, emoji)- emoji_reactions.create(user: user, emoji: emoji)+ emoji_reactions.create(user:, emoji:)enddef remove_reaction(user, emoji)- emoji_reactions.find_by(user: user, emoji: emoji)&.destroy+ emoji_reactions.find_by(user:, emoji:)&.destroyenddef grouped_emoji_reactions@@ -49,9 +49,9 @@ module Reactable# TODO: Refactor this to be database agnostic# fetch all emoji reactions and group them by emoji with their count and user idsemoji_groups = emoji_reactions- .select('emoji, COUNT(*) as count, ARRAY_AGG(user_id) as user_ids')+ .select("emoji, COUNT(*) as count, ARRAY_AGG(user_id) as user_ids").group(:emoji)- .order('emoji ASC')+ .order("emoji ASC")# avoid N+1 queries by preloading all reacting usersuser_ids = emoji_groups.flat_map(&:user_ids).uniq@@ -62,7 +62,7 @@ module Reactable{emoji: result.emoji,count: result.count,- users: result.user_ids.map { |id| { id: id, name: users[id].name } }+ users: result.user_ids.map { |id| { id:, name: users[id].name } }}end.index_by { |r| r[:emoji] }enddiff --git a/app/models/emoji_reaction.rb b/app/models/emoji_reaction.rbindex ef998557ee6..15c8468f37d 100644--- a/app/models/emoji_reaction.rb+++ b/app/models/emoji_reaction.rb@@ -44,13 +44,13 @@ class EmojiReaction < ApplicationRecordbelongs_to :reactable, polymorphic: truevalidates :emoji, presence: true, inclusion: { in: AVAILABLE_EMOJIS }- validates :user_id, uniqueness: { scope: [:reactable_type, :reactable_id, :emoji] }+ validates :user_id, uniqueness: { scope: %i[reactable_type reactable_id emoji] }def self.available_emojisAVAILABLE_EMOJISenddef self.shortcode(html_code)- EMOJI_MAP.key(html_code)&.to_s&.prepend(':')&.concat(':') || html_code+ EMOJI_MAP.key(html_code)&.to_s&.prepend(":")&.concat(":") || html_codeendenddiff --git a/db/migrate/20240624103354_create_emoji_reactions.rb b/db/migrate/20240624103354_create_emoji_reactions.rbindex 365aa4b7603..d0f6ac11456 100644--- a/db/migrate/20240624103354_create_emoji_reactions.rb+++ b/db/migrate/20240624103354_create_emoji_reactions.rb@@ -7,6 +7,7 @@ class CreateEmojiReactions < ActiveRecord::Migration[7.1]t.timestampsend- add_index :emoji_reactions, [:user_id, :reactable_type, :reactable_id, :emoji], unique: true, name: 'index_emoji_reactions_uniqueness'+ add_index :emoji_reactions, %i[user_id reactable_type reactable_id emoji], unique: true,+ name: "index_emoji_reactions_uniqueness"endend