Skip to content

Commit e799994

Browse files
authored
Merge pull request #1789 from coderdojo-japan/change-created-at-to-days-passed
feat: 掲載日を経過日に変更 (/dojos/activity)
2 parents 9dec0da + 66b623d commit e799994

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

app/views/dojos/activity.html.erb

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<br>
1919
<div class='form__terms list'>
2020
<ul style='list-style-type: "\2713\0020"; font-size: smaller;'>
21-
<li>「掲載日」は<%= link_to '統計情報 (道場別) ', dojos_path %> と同じロジックで表示しています。</li>
2221
<li>「記録日」は<%= link_to '統計情報 (開催数)', stats_path %> や活動の確認/記録日を表示しています。</li>
2322
<li>「記録日」は <a href='https://doorkeeper.jp/'>Doorkeeper</a><a href='http://connpass.com/'>connpass</a> の場合、自動で更新されます。</li>
23+
<li>「経過日」は記録日からの経過日数(<%= link_to '閾値', signup_path(anchor: 'terms') %>の確認用)を表示しています。</li>
2424
</ul>
2525
</div>
2626
</p>
@@ -38,16 +38,16 @@
3838
</th>
3939
<th>
4040
<small>
41-
🗾
41+
🗓
4242
<br class='ignore-pc'>
43-
<%= link_to '掲載日', signup_path %>
43+
<a href='<%= events_path %>'>記録日</a>
4444
</small>
4545
</th>
4646
<th>
4747
<small>
48-
🗓
48+
⏱️
4949
<br class='ignore-pc'>
50-
<a href='<%= events_path %>'>記録日</a>
50+
<%= link_to '経過日', signup_path(anchor: 'terms') %>
5151
</small>
5252
</th>
5353
<th>
@@ -82,9 +82,6 @@
8282
<% end %>
8383
</small>
8484
</td>
85-
<td class="<%= 'inactive-item' unless dojo[:is_active] %>">
86-
<small><%= dojo[:created_at].strftime("%Y-%m-%d") %></small>
87-
</td>
8885
<td class="<%= 'inactive-item' unless dojo[:is_active] %>">
8986
<small>
9087
<% if dojo[:note_date] && dojo[:latest_event_at] %>
@@ -128,6 +125,33 @@
128125
<% end %>
129126
</small>
130127
</td>
128+
<td class="<%= 'inactive-item' unless dojo[:is_active] %>">
129+
<small>
130+
<%
131+
# 記録日を決定(note_date と latest_event_at のより新しい方)
132+
record_date = nil
133+
if dojo[:note_date] && dojo[:latest_event_at]
134+
record_date = dojo[:note_date] > dojo[:latest_event_at] ? dojo[:note_date] : dojo[:latest_event_at]
135+
elsif dojo[:note_date]
136+
record_date = dojo[:note_date]
137+
elsif dojo[:latest_event_at]
138+
record_date = dojo[:latest_event_at]
139+
end
140+
141+
if record_date
142+
# 経過日数を計算
143+
days_passed = (Date.current - record_date.to_date).to_i
144+
expired = days_passed >= 365 && !dojo[:note]&.include?('Active')
145+
%>
146+
<span class="<%= 'expired' if expired %>">
147+
<%= days_passed %>
148+
</span>
149+
<% else %>
150+
<!-- 記録日がない場合 -->
151+
<span style="color: #999;">-</span>
152+
<% end %>
153+
</small>
154+
</td>
131155
<td class="<%= 'inactive-item' unless dojo[:is_active] %>">
132156
<small><small>
133157
<% search_query = URI.encode_www_form(q: "CoderDojo #{dojo[:name].split('@').first.strip}") %>

spec/requests/dojos_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,15 @@
431431

432432
it "displays proper column headers" do
433433
get activity_dojos_path
434-
expect(response.body).to include("掲載日")
434+
expect(response.body).to include("経過日")
435435
expect(response.body).to include("記録日")
436436
expect(response.body).to include("ノート")
437437
end
438438

439-
it "displays created_at date for active dojos" do
439+
it "displays days passed for active dojos" do
440440
get activity_dojos_path
441-
# 掲載日は YYYY-MM-DD 形式で表示される
442-
expect(response.body).to match(@active_dojo.created_at.strftime("%Y-%m-%d"))
441+
# 経過日は日数で表示される
442+
expect(response.body).to include("日")
443443
end
444444

445445
it "displays dojo ID same as /dojos page" do
@@ -644,9 +644,9 @@
644644
# Extract just the 記録日 column to check the date display
645645
td_matches = dojo_row.scan(/<td[^>]*>(.*?)<\/td>/m)
646646

647-
# Based on debug output: td_matches[1] is the 記録日 column
647+
# Based on debug output: td_matches[0] is the 記録日 column (列順変更後)
648648
# (道場名 column seems to be skipped in regex due to complex link structure)
649-
event_date_column = td_matches[1]&.first # 記録日 column
649+
event_date_column = td_matches[0]&.first # 記録日 column
650650

651651
expect(event_date_column).not_to be_nil, "Could not find 記録日 column"
652652

0 commit comments

Comments
 (0)