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
109109 # GET /dojos/activity
110110 # 道場の活動状況を表示(旧 /events/latest から移行)
111111 def activity
112+ # ビューで使用するための閾値をインスタンス変数に設定(モデルから取得)
113+ @inactive_threshold = Dojo ::INACTIVE_THRESHOLD
114+
112115 @latest_event_by_dojos = [ ]
113116 Dojo . active . each do |dojo |
114117 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
55 NUM_OF_TOTAL_EVENTS = "10,000"
66 NUM_OF_TOTAL_NINJAS = "62,000"
77 DOJO_INFO_YAML_PATH = Rails . root . join ( 'db' , 'dojos.yml' )
8+
9+ # 1年以上イベント開催していない道場を判定する閾値
10+ INACTIVE_THRESHOLD = 1 . year
811
912 belongs_to :prefecture
1013 has_many :dojo_event_services , dependent : :destroy
Original file line number Diff line number Diff line change 7474 < small >
7575 <% if dojo [ :latest_event_at ] %>
7676 <!-- イベント履歴がある場合 -->
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' ) %>
7878 < span class ="<%= 'expired' if expired %> ">
7979 <%= link_to dojo [ :latest_event_at ] . strftime ( "%Y-%m-%d" ) , dojo [ :latest_event_url ] %>
8080 </ span >
8181 <% elsif dojo [ :note_date ] %>
8282 <!-- 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' ) %>
8484 < span class ="<%= 'expired' if expired %> ">
8585 <% if dojo [ :note_link ] %>
8686 <%= link_to dojo [ :note_date ] . strftime ( "%Y-%m-%d" ) , dojo [ :note_link ] %>
You can’t perform that action at this time.
0 commit comments