Skip to content

Commit

Permalink
Fix for anonymous user, select uniq issues for daily report
Browse files Browse the repository at this point in the history
  • Loading branch information
arturtr committed Apr 9, 2016
1 parent 9d9497a commit 7aed8e9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/controllers/telegram_group_chats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@ def create
end

def destroy
current_user = User.current

@issue = Issue.visible.find(params[:id])
@project = @issue.project

telegram_id = @issue.telegram_group.telegram_id

@issue.telegram_group.destroy
@issue.init_journal(User.current, I18n.t('redmine_chat_telegram.journal.chat_was_closed'))

@issue.init_journal(current_user, I18n.t('redmine_chat_telegram.journal.chat_was_closed'))

if @issue.save
TelegramGroupCloseWorker.perform_async(telegram_id, User.current.id)
TelegramGroupCloseWorker.perform_async(telegram_id, current_user.id)
end

redirect_to @issue
Expand Down
2 changes: 1 addition & 1 deletion app/workers/telegram_group_daily_report_cron_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def perform
time_to = yesterday.end_of_day

Issue.joins(:telegram_messages).where('telegram_messages.sent_at >= ? and telegram_messages.sent_at <= ?',
time_from, time_to).find_each do |issue|
time_from, time_to).uniq.find_each do |issue|
TelegramGroupDailyReportWorker.perform_async(issue.id, yesterday.to_s)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/workers/telegram_group_daily_report_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def perform(issue_id, yesterday_string)


begin
issue.init_journal(User.current, journal_text)
issue.init_journal(User.anonymous, journal_text)
issue.save
rescue ActiveRecord::StaleObjectError
issue.reload
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/chat_telegram.rake
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace :chat_telegram do
telegram_message.message = message_text.gsub('/log', '')

journal_text = telegram_message.as_text(with_time: false)
issue.init_journal(User.current,
issue.init_journal(User.anonymous,
"_#{ I18n.t('redmine_chat_telegram.journal.from_telegram') }:_ \n\n#{journal_text}")
issue.save
end
Expand Down

0 comments on commit 7aed8e9

Please sign in to comment.