Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
59a9f22
events_helperの処理内容を見直し
zecky1120 May 25, 2026
7cacf2b
anouncementのコメント実装を修正
zecky1120 May 25, 2026
8409ec9
eventsのコメント実装を修正
zecky1120 May 26, 2026
b33f732
users/eventsのコメント実装を修正
zecky1120 May 26, 2026
b30325c
users/regular_eventsのコメント実装を修正
zecky1120 May 26, 2026
9144ebc
movies/:idのコメント実装を修正
zecky1120 May 26, 2026
d5541b9
pagesのコメント実装を修正
zecky1120 May 26, 2026
6f224b2
products配下のコメント実装を修正
zecky1120 May 26, 2026
1c8e6a7
regular_eventsのコメント実装を修正
zecky1120 May 27, 2026
708f9c7
reportsのコメント実装の修正
zecky1120 May 27, 2026
75ff6eb
pair_workのコメント実装とCSSの修正
zecky1120 May 27, 2026
74186fd
talkのコメント実装の修正
zecky1120 May 27, 2026
e0635fe
companies/:id/productsのコメント実装を修正
zecky1120 May 28, 2026
945a47c
アドバイザーアカウントで所属企業に所属しトップページで表示される研修生の日報一覧
zecky1120 Jun 1, 2026
7c1d776
html_safeからsafe_joinに処理を変更
zecky1120 Jun 1, 2026
d2a40fd
rails testで失敗したテスト文を修正
zecky1120 Jun 2, 2026
cba3c71
coderabbitの修正
zecky1120 Jun 3, 2026
cd50121
commentヘルパーのメソッド名を変更した
zecky1120 Jun 15, 2026
72fc6a6
メソッド名変更によるviewsも変更した
zecky1120 Jun 15, 2026
def9e24
N+1クエリ対策
zecky1120 Jun 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/stylesheets/atoms/_a-meta.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
font-weight: 600;
}

.a-meta.is-important .is-emphasized {
color: inherit;
}

a.a-meta {
text-decoration: none;
cursor: pointer;
Expand Down
4 changes: 2 additions & 2 deletions app/components/products/product_component.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
- else
| 約#{until_next_elapsed_days}時間

- if @product.comments.size > 0
- if @product.comments.any?
hr.card-list-item__row-separator
.card-list-item__row
.card-list-item-meta
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta コメント(#{@product.comments.size})
.a-meta = helpers.comment_count(@product)
.card-list-item-meta__item
.card-list-item__user-icons
- @product.commented_users.distinct.each do |user|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ReportsController < ApplicationController # rubocop:todo Metrics/ClassLeng
before_action :set_watch, only: %i[show]

def index
@reports = Report.list.page(params[:page]).per(PAGER_NUMBER)
@reports = Report.list.includes(:comments).page(params[:page]).per(PAGER_NUMBER)
@reports = @reports.joins(:practices).where(practices: { id: params[:practice_id] }) if params[:practice_id].present?
end

Expand Down
14 changes: 2 additions & 12 deletions app/helpers/events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ def google_calendar_url(event)
uri.to_s
end

def event_comment_count(event, styled: true)
length = event.comments.length

if styled
link_to '#comments', class: "a-meta #{'is-disabled' if length.zero?}" do
'コメント('.html_safe +
content_tag(:span, length, class: length.zero? ? 'is-muted' : 'is-emphasized') +
')'.html_safe
end
else
"コメント(#{length}名)"
end
def comment_count(commentable)
safe_join(['コメント(', content_tag(:span, commentable.comments.size, class: 'is-emphasized'), ')'])
end
Comment thread
zecky1120 marked this conversation as resolved.

def event_participant_count(event)
Expand Down
7 changes: 4 additions & 3 deletions app/views/announcements/_announcement.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| 公開
time.a-meta__value datetime=announcement.published_at.iso8601
| #{l announcement.published_at}
.card-list-item-meta__item
.a-meta
| コメント(#{announcement.comments.length})
- if announcement.comments.any?
.card-list-item-meta__item
.a-meta
= comment_count(announcement)
9 changes: 3 additions & 6 deletions app/views/announcements/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ hr.a-border
= @announcement.user.long_name
.page-content-header-metas__end
.page-content-header-metas__meta
- length = @announcement.comments.length
a.a-meta(href='#comments' class="#{length.zero? ? 'is-disabled' : ''}")
| コメント(
span#comment_count(class="#{length.zero? ? 'is-muted' : 'is-emphasized'}")
= length
| )
- if @announcement.comments.any?
a.a-meta(href='#comments')
= comment_count(@announcement)
.page-content-header__row
.page-content-header-actions
.page-content-header-actions__start
Expand Down
4 changes: 2 additions & 2 deletions app/views/companies/products/_product.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
time.a-meta datetime=product.updated_at.iso8601
span.a-meta__label 更新
| #{l product.updated_at}
- if !product.comments.empty?
- if product.comments.any?
hr.card-list-item__row-separator
.card-list-item__row
.card-list-item-meta
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
| コメント(#{product.comments.size})
= comment_count(product)
.card-list-item-meta__item
.card-list-item__user-icons
- commented_users[product.id].uniq.each do |user|
Expand Down
4 changes: 3 additions & 1 deletion app/views/events/_event.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
= l event.updated_at
.page-content-header-metas__end
.page-content-header-metas__meta
= event_comment_count(event, styled: true)
- if event.comments.any?
a.a-meta(href='#comments')
= comment_count(event)

.page-content-header__row
.page-content-header-actions
Expand Down
4 changes: 2 additions & 2 deletions app/views/events/_events.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ul.card-list.a-card
.card-list-item-meta__item
.a-meta
| 補欠者(#{event.waitlist.count}名)
- if event.comments.size.positive?
- if event.comments.any?
.card-list-item-meta__item
.a-meta
| コメント(#{event.comments.size})
= comment_count(event)
= paginate @events
4 changes: 2 additions & 2 deletions app/views/home/_colleague_trainee.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.card-list-item-meta__item
= link_to user_products_path(user), class: 'card-list-item-meta__item-link a-text-link' do
| 提出物一覧(#{user.products.count})
- if user.comments.present?
- if user.comments.any?
.card-list-item-meta__item
= link_to user_comments_path(user), class: 'card-list-item-meta__item-link a-text-link' do
| コメント(#{user.comments.count})
= comment_count(user)
16 changes: 6 additions & 10 deletions app/views/movies/_movie_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ header.page-content-header
= image_tag 'users/avatars/ghost.png', class: 'thread-header__user-icon a-user-icon'
.a-user-name
| ghost

.page-content-header-metas__end
.page-content-header-metas
.page-content-header-metas__meta
- length = movie.comments.length
a.a-meta(href='#comments' class="#{length.zero? ? 'is-disabled' : ''}")
| コメント(
span#comment_count(class="#{length.zero? ? 'is-muted' : 'is-emphasized'}")
= length
| )
- if movie.comments.any?
.page-content-header-metas__end
.page-content-header-metas
.page-content-header-metas__meta
a.a-meta(href='#comments')
= comment_count(movie)

.page-content-header__row
.page-content-header-actions
Expand Down
16 changes: 6 additions & 10 deletions app/views/pages/_doc_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,12 @@ header.page-content-header
image_class: 'thread-header__user-icon'
= link_to page.last_updated_user, class: 'a-user-name' do
| #{page.last_updated_user.login_name}

.page-content-header-metas__end
.page-content-header-metas
.page-content-header-metas__meta
- length = page.comments.length
a.a-meta(href='#comments' class="#{length.zero? ? 'is-disabled' : ''}")
| コメント(
span#comment_count(class="#{length.zero? ? 'is-muted' : 'is-emphasized'}")
= length
| )
- if page.comments.any?
.page-content-header-metas__end
.page-content-header-metas
.page-content-header-metas__meta
a.a-meta(href='#comments')
= comment_count(page)

.page-content-header__row
.page-content-header-actions
Expand Down
2 changes: 1 addition & 1 deletion app/views/pages/_page.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
- if page.comments.any?
.card-list-item-meta__item
.a-meta
| コメント(#{page.comments.length})
= comment_count(page)
7 changes: 4 additions & 3 deletions app/views/pair_works/_pair_work.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
- else
time.a-meta__value datetime=pair_work.published_at.iso8601
= l pair_work.published_at
.card-list-item-meta__item
.a-meta(class="#{pair_work.important? ? 'is-important' : ''}")
| コメント(#{pair_work.comments.length})
- if pair_work.comments.any?
.card-list-item-meta__item
.a-meta(class="is-important")
= comment_count(pair_work)

- if pair_work.solved?
.stamp.is-circle.is-solved
Expand Down
2 changes: 1 addition & 1 deletion app/views/products/_product.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
| コメント(#{product.comments.size})
= comment_count(product)
.card-list-item-meta__item
.card-list-item__user-icons
= render partial: 'users/icon',
Expand Down
14 changes: 5 additions & 9 deletions app/views/products/_product_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,11 @@ header.page-content-header.is-product
| 更新
time.a-meta__value datetime=product.updated_at.iso8601
= l product.updated_at

.page-content-header-metas__end
.page-content-header-metas__meta
- length = product.comments.length
a.a-meta(href='#comments' class="#{length.zero? ? 'is-disabled' : ''}")
| コメント(
span(class="#{length.zero? ? 'is-muted' : 'is-emphasized'}")
= length
| )
- if product.comments.any?
.page-content-header-metas__end
.page-content-header-metas__meta
a.a-meta(href='#comments')
= comment_count(product)

.page-content-header__row
.page-content-header-actions
Expand Down
2 changes: 1 addition & 1 deletion app/views/products/_product_list_item.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ruby:
hr.card-list-item__row-separator
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta コメント(#{product.comments.size})
.a-meta = comment_count(product)
.card-list-item-meta__item
.card-list-item__user-icons
= render partial: 'users/icon',
Expand Down
13 changes: 5 additions & 8 deletions app/views/regular_events/_regular_event.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
.a-meta
time.a-meta__value datetime=regular_event.updated_at.iso8601
= l regular_event.updated_at
.page-content-header-metas__end
.page-content-header-metas__meta
- length = regular_event.comments.length
a.a-meta(href='#comments' class="#{length.zero? ? 'is-disabled' : ''}")
| コメント(
span(class="#{length.zero? ? 'is-muted' : 'is-emphasized'}")
= length
| )
- if regular_event.comments.any?
.page-content-header-metas__end
.page-content-header-metas__meta
a.a-meta(href='#comments')
= comment_count(regular_event)

.page-content-header__row
.page-content-header-actions
Expand Down
5 changes: 2 additions & 3 deletions app/views/regular_events/_regular_events.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ ul.card-list.a-card
.a-meta
span.a-meta__label 開催日時
span.a-meta__value = "#{event.holding_cycles} #{l event.start_at, format: :time_only} ~ #{l event.end_at, format: :time_only}"
.card-list-item-meta__item
- if event.comments.size.positive?
- if event.comments.any?
.card-list-item-meta__item
.a-meta
| コメント(#{event.comments.size})
= comment_count(event)
= paginate @regular_events
2 changes: 1 addition & 1 deletion app/views/reports/_product.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
| コメント(#{product.comments.size})
= comment_count(product)
.card-list-item-meta__item
.card-list-item__user-icons
= render partial: 'comments/user_icons', collection: product.comments.commented_users, as: :user
Expand Down
2 changes: 1 addition & 1 deletion app/views/reports/_report.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
| コメント(#{report.comments.size})
= comment_count(report)
.card-list-item-meta__item
.card-list-item__user-icons
= render partial: 'comments/user_icons', collection: report.comments.commented_users, as: :user
Expand Down
9 changes: 3 additions & 6 deletions app/views/reports/_report_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ header.page-content-header.is-report

.page-content-header-metas__end
.page-content-header-metas__meta
- length = report.comments.length
a.a-meta(href='#comments' class="#{length.zero? ? 'is-disabled' : ''}")
| コメント(
span(class="#{length.zero? ? 'is-muted' : 'is-emphasized'}")
= length
| )
- if report.comments.any?
a.a-meta(href='#comments')
= comment_count(report)

.page-content-header__row
.page-content-header-actions
Expand Down
5 changes: 2 additions & 3 deletions app/views/talks/_talk.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
h2.card-list-item-title__title(itemprop='name')
= link_to "/talks/#{talk.id}#latest-comment", itemprop: 'url', class: 'card-list-item-title__link a-text-link' do
| #{talk.user.long_name} さんの相談部屋
- if talk.comments.present?
- if talk.comments.any?
hr.card-list-item__row-separator
- if talk.comments.present?
.card-list-item__row
.card-list-item-meta__items
.card-list-item-meta__item
.card-list-item-meta
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
| コメント(#{talk.comments.size})
= comment_count(talk)
.card-list-item-meta__item
.card-list-item__user-icons
= render partial: 'users/icon',
Expand Down
4 changes: 2 additions & 2 deletions app/views/users/events/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
.card-list-item-meta__item
.a-meta
= event_waitlist_count(event)
- if event.comments.size.positive?
- if event.comments.any?
.card-list-item-meta__item
.a-meta
= event_comment_count(event, styled: false)
= comment_count(event)
.pagination
= paginate @events
- else
Expand Down
4 changes: 2 additions & 2 deletions app/views/users/regular_events/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
time.a-meta(datetime="#{event.start_at}")
| 開催日時:
| #{event.holding_cycles} #{l event.start_at, format: :time_only} ~ #{l event.end_at, format: :time_only}
- if event.comments.size.positive?
- if event.comments.any?
.card-list-item-meta__item
.a-meta
= event_comment_count(event, styled: false)
= comment_count(event)
.pagination
= paginate @regular_events
- else
Expand Down
2 changes: 1 addition & 1 deletion test/system/announcements_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AnnouncementsTest < ApplicationSystemTestCase
assert_selector 'p', text: 'コメント数表示のテストです。'

visit current_path
assert_selector '#comment_count', text: '2'
assert_selector 'a.a-meta[href="#comments"] span.is-emphasized', text: '2'
end

test 'using file uploading by file selection dialogue in textarea' do
Expand Down
3 changes: 1 addition & 2 deletions test/system/movies_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ class MoviesTest < ApplicationSystemTestCase
content_type: 'video/mp4'
)
visit_with_auth "/movies/#{movie.id}", 'kimura'
assert_selector '#comment_count', text: 0

wait_for_comment_form
post_comment('コメント数表示のテストです。')

visit_with_auth "/movies/#{movie.id}", 'kimura'
wait_for_javascript_components
assert_selector '#comment_count', text: 1
assert_selector 'a.a-meta[href="#comments"] span.is-emphasized', text: 1
end

test 'show the edit movie page' do
Expand Down
3 changes: 1 addition & 2 deletions test/system/pages_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ class PagesTest < ApplicationSystemTestCase
test 'show comment count' do
page = pages(:page1)
visit_with_auth "/pages/#{page.id}", 'kimura'
assert_selector '#comment_count', text: 0

wait_for_comment_form
post_comment('コメント数表示のテストです。')

visit current_path
wait_for_javascript_components
assert_selector '#comment_count', text: 1
assert_selector 'span.is-emphasized', text: 1
end

test 'show last updated user icon' do
Expand Down
2 changes: 1 addition & 1 deletion test/system/product/product_list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Product::ProductListTest < ApplicationSystemTestCase
visit_with_auth '/products', 'komagata'
product_item = find("a[href='/products/#{product.id}']").ancestor('.card-list-item')
within product_item do
assert_text "コメント(#{product.comments.size})"
assert_text(/コメント(\s*#{product.comments.size}\s*)/)
assert_selector '.card-list-item__user-icons'
end
end
Expand Down
Loading
Loading