From f526db16ee8d586d616fa14e3262500ad76ed70a Mon Sep 17 00:00:00 2001 From: "mr.exz" Date: Wed, 1 Nov 2023 18:47:08 +0300 Subject: [PATCH] fix --- CHANGELOG.md | 1 + bot/commands/channel_labels_merge.rb | 8 ++++---- config/locales/en.yml | 6 ++++++ config/locales/hr.yml | 7 +++++++ config/locales/ru.yml | 7 +++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 074f2cc..cb47f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## 0.10.1 ### Improvements +- Deleting no needed code - Added `channel labels merge` ## 0.10.0 diff --git a/bot/commands/channel_labels_merge.rb b/bot/commands/channel_labels_merge.rb index f325420..aa2aa35 100644 --- a/bot/commands/channel_labels_merge.rb +++ b/bot/commands/channel_labels_merge.rb @@ -2,16 +2,16 @@ module WhoIsOnDutyTodaySlackBotModule module Commands class ChannelLabelsMerge def self.call(client:, data:, match:) - label_from = match["expression"][/from:(.*) action:/, 1] + label_from = match["expression"][/from:(.*) to:/, 1] label_to = match["expression"][/ to:(.*)$/, 1] label_to_id = Label.where(label: label_to).ids[0] if (label_from != nil?) || (label_to_id != nil?) m = SlackThreadLabel.joins(:label, :slack_thread).where(slack_thread: {channel_id: data.channel}, label: {label: label_from}) - m.update_all(label_id: label_to_id) - message = "label_from label_to merged" + records_affected=m.update_all(label_id: label_to_id) + message = I18n.t("commands.channel.labels.merged.success.text",label_from:label_from,label_to:label_to,records_affected:records_affected) else - message = "Sorry, label_from or label_to not found, merge not possible." + message = I18n.t("commands.channel.labels.merged.error.text",label_from:label_from,label_to:label_to) end client.web_client.chat_postMessage( channel: data.channel, diff --git a/config/locales/en.yml b/config/locales/en.yml index 92edba6..a162cb9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -31,6 +31,12 @@ en: -- `my status *` - set any status when you cannot provide support in channel, bot will reply instead of you. -- `my status work` - bot will stop telling your status, use it when you came back. channel: + labels: + merged: + success: + text: "Labels merged %{label_from} -> %{label_to} records affected %{records_count}" + error: + text: "Merge %{label_from} -> %{label_to} failed, check label names" reminder: enabled: text: "Reminder in channel successfully enabled." diff --git a/config/locales/hr.yml b/config/locales/hr.yml index 2777845..79a068d 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -43,6 +43,13 @@ hr: action: failed: text: "" + channel: + labels: + merged: + error: + text: "" + success: + text: "" reply: non-working-time: subject: "Nešto se dogodilo" diff --git a/config/locales/ru.yml b/config/locales/ru.yml index c5d5877..d0a7847 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -43,6 +43,13 @@ ru: action: failed: text: "" + channel: + labels: + merged: + error: + text: "" + success: + text: "" reply: non-working-time: subject: "Что то случилось"