Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification feature #728

Merged
merged 12 commits into from
Feb 12, 2021
Merged

Add notification feature #728

merged 12 commits into from
Feb 12, 2021

Conversation

kimurabps
Copy link
Collaborator

@kimurabps kimurabps commented Jan 28, 2021

refs #712

対応内容

ジョブ完了通知機能を実装しました。

スクリーンショット

ナビゲーションメニューにベルアイコンを追加
bell

ベルアイコン押下で通知を10件まで表示
message_list

「more...」押下で通知一覧ページに遷移
events_index

ナビゲーションに「Setting」メニューを追加し、通知粒度とWebhook URLを設定できるようにする
setting

Webhook URLが設定されている場合はSlack通知を行う
slack

@kimurabps kimurabps marked this pull request as ready for review February 4, 2021 08:01
@kimurabps kimurabps requested a review from yohm February 4, 2021 08:02
@kimurabps
Copy link
Collaborator Author

kimurabps commented Feb 4, 2021

レビュー依頼後で申し訳ございませんが、
ParameterSetに紐づくAnalysisの存在チェックがなぜかうまくいかない問題がありましたので、修正をプッシュしました 🙇

Analysis.last.parameter_set.analyses.last.status
=> :finished

Analysis.last.parameter_set.analyses.exists?
=> false

Analysis.last.parameter_set.analyses.present?
=> true

Analysis.last.parameter_set.analyses.where(status: :finished).present?
=> false

Analysis.where(parameter_set: Analysis.last.parameter_set).where(status: :finished).exists?
=> true

@kimurabps
Copy link
Collaborator Author

@yohm Slackにてご指摘いただいた以下の修正をpushいたしました 🙇

* oracle_hostの設定がなければ localhost:3000 にフォールバックする
* 通知が10件を超えたら古いものを消す

@yohm
Copy link
Member

yohm commented Feb 8, 2021

@kimurabps 早速対応いただきましてありがとうございます。修正を確認しました。

@yohm
Copy link
Member

yohm commented Feb 9, 2021

@kimurabps 上のコメントで述べたようにuser_config['oacis_host'] の値をslack通知する場合にのみ参照するようにした場合、設定をuser_configではなくSettingsの画面で設定するようにするとより簡単にセットアップができるのではないかと考えています。
Settingsの設定項目として1項目(項目名は"OACIS URL" とか?良い名前があればご提案していただければありがたいです) 追加して、設定のデフォルト値をJSでdocument.location.originにしたいと考えています。この仕様で問題なさそうでしょうか?

Copy link
Member

@yohm yohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

とても完成度も高くて、使いやすい機能でした。設定のUIも通知のUIもslackへの連携も思い描いていた通りのものができています。
主に文言や設定方法についてコメントしましたのでご検討いただけるとありがたいです。

module NotificationEventsHelper
def generate_all_jobs_in_simulator_finished_message(job)
simulator_id = job.simulator.id
id_link = link_to(shortened_id(simulator_id), simulator_url(simulator_id))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OACISのUI上から参照するリンクは_urlではなく_pathにして、user_config[oacis_host]に依存しないようにできないでしょうか?
slackと連携させずに使う人も多いと思われますので、slackにメッセージを送る際のみoacis_hostの値を参照するようにすると、ユーザーのセットアップがより簡便になると思っています。

simulator_id = job.simulator.id
id_link = link_to(shortened_id(simulator_id), simulator_url(simulator_id))

return "All #{job.class} in SimulatorID #{id_link} finished."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文言ですが、Simulatorの場合のみ、IDではなくnameを表示していただいた方が使いやすいと思います。
id_linkを作る際に shortened_id(simulator_id)ではなく job.simulator.name を使うようにしてもらえませんか?


def update
if @oacis_setting.update(oacis_setting_params)
redirect_to edit_oacis_setting_path, notice: 'Oacis setting was successfully updated.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slackのwebhook登録時または更新時に、実際にslackに通知("OACIS setting was successfully updated"などの文言)を送っていただけないでしょうか?
ユーザーが、webhookの設定が正しく行われたことを確認できるようにするという意図です。

.col-md-2
= f.select :notification_level, [1, 2, 3], {}, class: 'form-control', data: tooltip_data(:oacis_setting, :notification_level)
.form-group
= f.label_c :webhook_url
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文言を "Webhook url" から "Slack webhook URL" に変更していただけないでしょうか?

.form-group
= f.label_c :webhook_url
.col-md-5
= f.text_field :webhook_url, class: 'form-control', data: tooltip_data(:oacis_setting, :webhook_url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このテキストフィールドの直下に以下のようなリンクを貼って、ユーザーがどのようにslackを設定するかがわかるようにしたいと考えています。特に問題なさそうであれば追加していただけないでしょうか?

How to setup incoming webhook for slack.

@kimurabps
Copy link
Collaborator Author

@kimurabps 上のコメントで述べたようにuser_config['oacis_host'] の値をslack通知する場合にのみ参照するようにした場合、設定をuser_configではなくSettingsの画面で設定するようにするとより簡単にセットアップができるのではないかと考えています。
Settingsの設定項目として1項目(項目名は"OACIS URL" とか?良い名前があればご提案していただければありがたいです) 追加して、設定のデフォルト値をJSでdocument.location.originにしたいと考えています。この仕様で問題なさそうでしょうか?

@yohm レビューいただきありがとうございます 🙇
おっしゃるとおり、oacis_urlはslack通知する場合のみ参照し、設定はSettingsの画面から行えるようにした方がよさそうです 🙇
念のため確認させていただきたいのですが、「設定のデフォルト値をJSで document.location.origin にする」というのは、
oacis_urlが未設定の場合に、設定画面の入力ボックスにJSでデフォルト値としてセットするという認識で合っておりますでしょうか?
(未設定のまま使用した場合は document.location.origin は参照できないので、http://localhost:3000 にフォールバックする)

@yohm
Copy link
Member

yohm commented Feb 9, 2021

@kimurabps

oacis_urlが未設定の場合に、設定画面の入力ボックスにJSでデフォルト値としてセットするという認識で合っておりますでしょうか?
(未設定のまま使用した場合は document.location.origin は参照できないので、http://localhost:3000 にフォールバックする)

おっしゃる通りです。ご指摘の通りフォールバックも必要ですね。

@kimurabps
Copy link
Collaborator Author

ご回答ありがとうございます。承知いたしました。

@kimurabps
Copy link
Collaborator Author

@yohm 指摘箇所を修正いたしましたので、お手すきの際にレビューをお願いいたします 🙇

Copy link
Member

@yohm yohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

素晴らしいです!ありがとうございます

@yohm yohm merged commit 8a6e06c into develop Feb 12, 2021
@yohm yohm deleted the feature/add_notification branch February 12, 2021 04:12
@yohm yohm added this to the Improvement-202103 milestone Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants