-
Notifications
You must be signed in to change notification settings - Fork 75
OrganizerをRegularEventOrganizerにリネームした #9715
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,13 +58,13 @@ class RegularEvent < ApplicationRecord # rubocop:disable Metrics/ClassLength | |||||
|
|
||||||
| scope :holding, -> { where(finished: false) } | ||||||
| scope :participated_by, ->(user) { where(id: all.filter { |e| e.participated_by?(user) }.map(&:id)) } | ||||||
| scope :organizer_event, ->(user) { joins(:organizers).where(organizers: { user_id: user.id }) } | ||||||
| scope :organizer_event, ->(user) { joins(:regular_event_organizers).where(regular_event_organizers: { user_id: user.id }) } | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [NITS]
Suggested change
|
||||||
| scope :scheduled_on, ->(date) { holding.filter { |event| event.scheduled_on?(date) } } | ||||||
| scope :scheduled_on_without_ended, ->(date) { holding.filter { |event| event.scheduled_on?(date) && !event.ended?(date) } } | ||||||
|
|
||||||
| belongs_to :user | ||||||
| has_many :organizers, dependent: :destroy | ||||||
| has_many :users, through: :organizers | ||||||
| has_many :regular_event_organizers, dependent: :destroy | ||||||
| has_many :users, through: :regular_event_organizers | ||||||
| has_many :regular_event_repeat_rules, dependent: :destroy | ||||||
| accepts_nested_attributes_for :regular_event_repeat_rules, allow_destroy: true | ||||||
| has_many :regular_event_participations, dependent: :destroy | ||||||
|
|
@@ -102,6 +102,7 @@ def next_event_date | |||||
| end | ||||||
|
|
||||||
| def organizers | ||||||
| # TODO: order内のorganizersをテーブル名を変えた時にregular_event_organizersに変更する | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [LGTM] |
||||||
| users.preload(avatar_attachment: :blob).order('organizers.created_at') | ||||||
| end | ||||||
|
|
||||||
|
|
@@ -122,7 +123,7 @@ def assign_admin_as_organizer_if_none | |||||
| return if organizers.exists? | ||||||
|
|
||||||
| admin_user = User.find_by(login_name: User::DEFAULT_REGULAR_EVENT_ORGANIZER) | ||||||
| Organizer.new(user: admin_user, regular_event: self).save if admin_user | ||||||
| RegularEventOrganizer.new(user: admin_user, regular_event: self).save if admin_user | ||||||
| end | ||||||
|
|
||||||
| def all_scheduled_dates( | ||||||
|
|
||||||
5 changes: 4 additions & 1 deletion
5
app/models/organizer.rb → app/models/regular_event_organizer.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'test_helper' | ||
|
|
||
| class RegularEventOrganizerTest < ActiveSupport::TestCase | ||
| test '#delete_and_assign_new' do | ||
| organizer = organizers(:organizer12) | ||
| event = organizer.regular_event | ||
|
|
||
| assert_changes -> { RegularEventOrganizer.where(regular_event: event, user: organizer.user).exists? }, from: true, to: false do | ||
| organizer.delete_and_assign_new | ||
| end | ||
|
|
||
| assert RegularEventOrganizer.where(regular_event: event).exists? | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
git ls-files app/controllers/regular_events_controller.rb app/models/regular_event*.rbRepository: fjordllc/bootcamp
Length of output: 343
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 1544
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 903
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 298
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 361
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 516
🏁 Script executed:
cat -n app/models/regular_event.rb | head -80Repository: fjordllc/bootcamp
Length of output: 3139
🏁 Script executed:
rg -A 3 "class RegularEventOrganizer" app/models/Repository: fjordllc/bootcamp
Length of output: 709
🏁 Script executed:
rg "EventOrganizer\." app/controllers/ -A 2 -B 2Repository: fjordllc/bootcamp
Length of output: 582
🏁 Script executed:
rg "\.create\(" app/controllers/regular_events_controller.rbRepository: fjordllc/bootcamp
Length of output: 158
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 502
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 761
🏁 Script executed:
rg -B 5 -A 5 "RegularEventOrganizer" app/controllers/Repository: fjordllc/bootcamp
Length of output: 1017
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 43
🏁 Script executed:
rg "\.create\!" app/models/regular_event.rb -B 2 -A 2Repository: fjordllc/bootcamp
Length of output: 145
🏁 Script executed:
rg "create!" app/models/regular_event.rb -B 2 -A 2Repository: fjordllc/bootcamp
Length of output: 43
🏁 Script executed:
rg "transaction" app/controllers/regular_events_controller.rbRepository: fjordllc/bootcamp
Length of output: 43
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 2223
🏁 Script executed:
rg "regular_event_organizers" app/models/regular_event.rb -B 2 -A 2Repository: fjordllc/bootcamp
Length of output: 999
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 569
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 655
🏁 Script executed:
rg "set_all_user_participants_and_watchers" app/controllers/regular_events_controller.rb -A 10Repository: fjordllc/bootcamp
Length of output: 865
🏁 Script executed:
Repository: fjordllc/bootcamp
Length of output: 818
🏁 Script executed:
rg "belongs_to :user" app/models/regular_event_organizer.rb -B 1 -A 5Repository: fjordllc/bootcamp
Length of output: 201
主催者レコード作成失敗が握りつぶされます。
createメソッドは検証失敗時に例外を発生させず、戻り値も確認していないため、作成失敗時でも成功フローが続行されます。主催者関係が紐付けられず、イベントが不完全な状態になるリスクがあります。修正案
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既存の定期イベントに自動で作成者を主催者を作成する機能のバグなので別Issueとして対応いたします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yokomaruさん、承知いたしました。PRのスコープを維持し、別Issueで対応されるのは適切な判断だと思います。この問題(RegularEventOrganizerの作成失敗時のエラーハンドリング)について、GitHubのIssueを作成しますか?必要であれば、適切なタイトルと説明文を付けてIssueを作成させていただきます。
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このリポジトリに登録してあるバグレポートのフォーマットに沿って作成お願いします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@yokomaruさん、承知いたしました。リポジトリのバグレポートフォーマットを確認して、Issue を作成させていただきます。🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 675
🏁 Script executed:
Length of output: 541
🏁 Script executed:
Length of output: 16
🏁 Script executed:
Length of output: 616
🏁 Script executed:
Length of output: 88
🏁 Script executed:
Length of output: 48
@yokomaruさん、バグレポートのフォーマットに沿って Issue を作成いたしました。作成された Issue:
#9716
「RegularEventOrganizer作成失敗時のエラーハンドリング不足」というタイトルで、以下の内容を含めています:
RegularEventOrganizer.createのエラーハンドリング不足の説明#9715とコメントURLを記載ご確認よろしくお願いいたします。
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます!問題ありませんでした。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yokomaruさん、どういたしまして!今後の対応、よろしくお願いいたします。🧠 Learnings used
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[NITS]
@yokomaru も触れてた気がするけど、修正時にここの記述も直してよいかもしれませんね。
どっちでもいいけどその方がやっぱり Ruby on Rails っぽいよね。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.