File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ def show
109
109
# GET /dojos/activity
110
110
# 道場の活動状況を表示(旧 /events/latest から移行)
111
111
def activity
112
+ # ビューで使用するための閾値をインスタンス変数に設定(モデルから取得)
113
+ @inactive_threshold = Dojo ::INACTIVE_THRESHOLD
114
+
112
115
@latest_event_by_dojos = [ ]
113
116
Dojo . active . each do |dojo |
114
117
link_in_note = dojo . note . match ( URI . regexp )
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ class Dojo < ApplicationRecord
5
5
NUM_OF_TOTAL_EVENTS = "10,000"
6
6
NUM_OF_TOTAL_NINJAS = "62,000"
7
7
DOJO_INFO_YAML_PATH = Rails . root . join ( 'db' , 'dojos.yml' )
8
+
9
+ # 1年以上イベント開催していない道場を判定する閾値
10
+ INACTIVE_THRESHOLD = 1 . year
8
11
9
12
belongs_to :prefecture
10
13
has_many :dojo_event_services , dependent : :destroy
Original file line number Diff line number Diff line change 74
74
< small >
75
75
<% if dojo [ :latest_event_at ] %>
76
76
<!-- イベント履歴がある場合 -->
77
- <% expired = dojo [ :latest_event_at ] <= Time . current . prev_year && !dojo [ :note ] . include? ( 'Active' ) %>
77
+ <% expired = dojo [ :latest_event_at ] <= Time . current - @inactive_threshold && !dojo [ :note ] . include? ( 'Active' ) %>
78
78
< span class ="<%= 'expired' if expired %> ">
79
79
<%= link_to dojo [ :latest_event_at ] . strftime ( "%Y-%m-%d" ) , dojo [ :latest_event_url ] %>
80
80
</ span >
81
81
<% elsif dojo [ :note_date ] %>
82
82
<!-- note内に日付がある場合 -->
83
- <% expired = dojo [ :note_date ] <= Time . current . prev_year && !dojo [ :note ] . include? ( 'Active' ) %>
83
+ <% expired = dojo [ :note_date ] <= Time . current - @inactive_threshold && !dojo [ :note ] . include? ( 'Active' ) %>
84
84
< span class ="<%= 'expired' if expired %> ">
85
85
<% if dojo [ :note_link ] %>
86
86
<%= link_to dojo [ :note_date ] . strftime ( "%Y-%m-%d" ) , dojo [ :note_link ] %>
You can’t perform that action at this time.
0 commit comments