Skip to content

Commit 06c414e

Browse files
committed
Merge branch 'main' into patch-3
2 parents b9f478a + 9d12b39 commit 06c414e

27 files changed

+458
-468
lines changed

Gemfile.lock

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (8.0.2)
5-
actionpack (= 8.0.2)
6-
activesupport (= 8.0.2)
4+
actioncable (8.0.2.1)
5+
actionpack (= 8.0.2.1)
6+
activesupport (= 8.0.2.1)
77
nio4r (~> 2.0)
88
websocket-driver (>= 0.6.1)
99
zeitwerk (~> 2.6)
10-
actionmailbox (8.0.2)
11-
actionpack (= 8.0.2)
12-
activejob (= 8.0.2)
13-
activerecord (= 8.0.2)
14-
activestorage (= 8.0.2)
15-
activesupport (= 8.0.2)
10+
actionmailbox (8.0.2.1)
11+
actionpack (= 8.0.2.1)
12+
activejob (= 8.0.2.1)
13+
activerecord (= 8.0.2.1)
14+
activestorage (= 8.0.2.1)
15+
activesupport (= 8.0.2.1)
1616
mail (>= 2.8.0)
17-
actionmailer (8.0.2)
18-
actionpack (= 8.0.2)
19-
actionview (= 8.0.2)
20-
activejob (= 8.0.2)
21-
activesupport (= 8.0.2)
17+
actionmailer (8.0.2.1)
18+
actionpack (= 8.0.2.1)
19+
actionview (= 8.0.2.1)
20+
activejob (= 8.0.2.1)
21+
activesupport (= 8.0.2.1)
2222
mail (>= 2.8.0)
2323
rails-dom-testing (~> 2.2)
24-
actionpack (8.0.2)
25-
actionview (= 8.0.2)
26-
activesupport (= 8.0.2)
24+
actionpack (8.0.2.1)
25+
actionview (= 8.0.2.1)
26+
activesupport (= 8.0.2.1)
2727
nokogiri (>= 1.8.5)
2828
rack (>= 2.2.4)
2929
rack-session (>= 1.0.1)
3030
rack-test (>= 0.6.3)
3131
rails-dom-testing (~> 2.2)
3232
rails-html-sanitizer (~> 1.6)
3333
useragent (~> 0.16)
34-
actiontext (8.0.2)
35-
actionpack (= 8.0.2)
36-
activerecord (= 8.0.2)
37-
activestorage (= 8.0.2)
38-
activesupport (= 8.0.2)
34+
actiontext (8.0.2.1)
35+
actionpack (= 8.0.2.1)
36+
activerecord (= 8.0.2.1)
37+
activestorage (= 8.0.2.1)
38+
activesupport (= 8.0.2.1)
3939
globalid (>= 0.6.0)
4040
nokogiri (>= 1.8.5)
41-
actionview (8.0.2)
42-
activesupport (= 8.0.2)
41+
actionview (8.0.2.1)
42+
activesupport (= 8.0.2.1)
4343
builder (~> 3.1)
4444
erubi (~> 1.11)
4545
rails-dom-testing (~> 2.2)
4646
rails-html-sanitizer (~> 1.6)
47-
activejob (8.0.2)
48-
activesupport (= 8.0.2)
47+
activejob (8.0.2.1)
48+
activesupport (= 8.0.2.1)
4949
globalid (>= 0.3.6)
50-
activemodel (8.0.2)
51-
activesupport (= 8.0.2)
52-
activerecord (8.0.2)
53-
activemodel (= 8.0.2)
54-
activesupport (= 8.0.2)
50+
activemodel (8.0.2.1)
51+
activesupport (= 8.0.2.1)
52+
activerecord (8.0.2.1)
53+
activemodel (= 8.0.2.1)
54+
activesupport (= 8.0.2.1)
5555
timeout (>= 0.4.0)
56-
activestorage (8.0.2)
57-
actionpack (= 8.0.2)
58-
activejob (= 8.0.2)
59-
activerecord (= 8.0.2)
60-
activesupport (= 8.0.2)
56+
activestorage (8.0.2.1)
57+
actionpack (= 8.0.2.1)
58+
activejob (= 8.0.2.1)
59+
activerecord (= 8.0.2.1)
60+
activesupport (= 8.0.2.1)
6161
marcel (~> 1.0)
62-
activesupport (8.0.2)
62+
activesupport (8.0.2.1)
6363
base64
6464
benchmark (>= 0.3)
6565
bigdecimal
@@ -100,9 +100,9 @@ GEM
100100
aws-sigv4 (1.11.0)
101101
aws-eventstream (~> 1, >= 1.0.2)
102102
backport (1.2.0)
103-
base64 (0.2.0)
104-
benchmark (0.4.0)
105-
bigdecimal (3.1.9)
103+
base64 (0.3.0)
104+
benchmark (0.4.1)
105+
bigdecimal (3.2.2)
106106
bindex (0.8.1)
107107
bootsnap (1.18.6)
108108
msgpack (~> 1.2)
@@ -303,20 +303,20 @@ GEM
303303
woothee (>= 1.0.0)
304304
rackup (2.2.1)
305305
rack (>= 3)
306-
rails (8.0.2)
307-
actioncable (= 8.0.2)
308-
actionmailbox (= 8.0.2)
309-
actionmailer (= 8.0.2)
310-
actionpack (= 8.0.2)
311-
actiontext (= 8.0.2)
312-
actionview (= 8.0.2)
313-
activejob (= 8.0.2)
314-
activemodel (= 8.0.2)
315-
activerecord (= 8.0.2)
316-
activestorage (= 8.0.2)
317-
activesupport (= 8.0.2)
306+
rails (8.0.2.1)
307+
actioncable (= 8.0.2.1)
308+
actionmailbox (= 8.0.2.1)
309+
actionmailer (= 8.0.2.1)
310+
actionpack (= 8.0.2.1)
311+
actiontext (= 8.0.2.1)
312+
actionview (= 8.0.2.1)
313+
activejob (= 8.0.2.1)
314+
activemodel (= 8.0.2.1)
315+
activerecord (= 8.0.2.1)
316+
activestorage (= 8.0.2.1)
317+
activesupport (= 8.0.2.1)
318318
bundler (>= 1.15.0)
319-
railties (= 8.0.2)
319+
railties (= 8.0.2.1)
320320
rails-controller-testing (1.0.5)
321321
actionpack (>= 5.0.1.rc1)
322322
actionview (>= 5.0.1.rc1)
@@ -328,9 +328,9 @@ GEM
328328
rails-html-sanitizer (1.6.2)
329329
loofah (~> 2.21)
330330
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
331-
railties (8.0.2)
332-
actionpack (= 8.0.2)
333-
activesupport (= 8.0.2)
331+
railties (8.0.2.1)
332+
actionpack (= 8.0.2.1)
333+
activesupport (= 8.0.2.1)
334334
irb (~> 1.13)
335335
rackup (>= 1.0.0)
336336
rake (>= 12.2)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ coderdojo.jp の開発には以下のいずれかの方法で参加できます
3939

4040
Dojo 情報は次の手順で簡単に更新できます。
4141

42-
1. [db/dojos.yaml](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/dojos.yaml) を開く
42+
1. [db/dojos.yml](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/dojos.yml) を開く
4343
2. 画面右にある ✎ アイコン (Fork this project and edit this file) をクリックする
4444
3. 気になる箇所を修正し、修正内容にタイトルと説明文を付け、Propose file change をクリックする
4545
4. 修正内容を確認し、問題なければ Create pull request をクリックする
@@ -157,10 +157,10 @@ bundle exec rails db:migrate
157157
# 開発用データの流し込み(seeding)
158158
bundle exec rails db:seed
159159

160-
# db/dojos.yaml の内容をDBに反映するタスク
160+
# db/dojos.yml の内容をDBに反映するタスク
161161
bundle exec rails dojos:update_db_by_yaml
162162

163-
# DBの内容を db/dojos.yaml に反映するタスク
163+
# DBの内容を db/dojos.yml に反映するタスク
164164
bundle exec rails dojos:migrate_adding_id_to_yaml
165165

166166
# 近日開催の道場を更新するタスク
@@ -242,8 +242,8 @@ We use `SCRIVITO_TENANT` and `SCRIVITO_API_KEY` keys in production, but they are
242242
なお本サイト内 DB の各テーブルおよびそのデータ(一般公開部分のみ)は、以下のファイルからご確認いただけます。
243243

244244
- DB テーブル: [`db/schema.rb`](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/schema.rb)
245-
- Dojo データ: [`db/dojos.yaml`](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/dojo_event_services.yaml)
246-
- Event データ (の情報取得元): [`db/dojo_event_services.yaml`](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/dojo_event_services.yaml)
245+
- Dojo データ: [`db/dojos.yml`](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/dojos.yml)
246+
- Event データ (の情報取得元): [`db/dojo_event_services.yml`](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/dojo_event_services.yml)
247247
- :memo: 1つの Dojo が複数のイベント管理サービスを使う事例もあるため [`Dojo has_many DojoEventServices`](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/app/models/dojo.rb) となっています。
248248

249249

app/controllers/dojos_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def index
2828
end
2929

3030
@dojos = []
31-
dojos_scope.includes(:prefecture).order(is_active: :desc, order: :asc).each do |dojo|
31+
dojos_scope.includes(:prefecture).order_by_active_status.order(order: :asc).each do |dojo|
3232
# 年が選択されている場合は、その年末時点でのアクティブ状態を判定
3333
# 選択されていない場合は、現在の is_active を使用
3434
is_active_at_selected_time = if @selected_year
3535
# その年末時点でアクティブだったかを判定
3636
# inactivated_at が nil(まだアクティブ)または選択年より後に非アクティブ化
3737
dojo.inactivated_at.nil? || dojo.inactivated_at > Time.zone.local(@selected_year).end_of_year
3838
else
39-
dojo.is_active
39+
dojo.active?
4040
end
4141

4242
@dojos << {

app/models/dojo.rb

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Dojo < ApplicationRecord
44
NUM_OF_ANNUAL_NINJAS = "7,000"
55
NUM_OF_TOTAL_EVENTS = "10,000"
66
NUM_OF_TOTAL_NINJAS = "62,000"
7-
DOJO_INFO_YAML_PATH = Rails.root.join('db', 'dojos.yaml')
7+
DOJO_INFO_YAML_PATH = Rails.root.join('db', 'dojos.yml')
88

99
belongs_to :prefecture
1010
has_many :dojo_event_services, dependent: :destroy
@@ -14,8 +14,13 @@ class Dojo < ApplicationRecord
1414
before_save { self.email = self.email.downcase }
1515

1616
scope :default_order, -> { order(prefecture_id: :asc, order: :asc) }
17-
scope :active, -> { where(is_active: true ) }
18-
scope :inactive, -> { where(is_active: false) }
17+
scope :active, -> { where(inactivated_at: nil) }
18+
scope :inactive, -> { where.not(inactivated_at: nil) }
19+
20+
# ソート用スコープ: アクティブな道場を先に表示
21+
scope :order_by_active_status, -> {
22+
order(Arel.sql('CASE WHEN inactivated_at IS NULL THEN 0 ELSE 1 END'))
23+
}
1924

2025
# 新しいスコープ: 特定の日時点でアクティブだったDojoを取得
2126
scope :active_at, ->(date) {
@@ -103,27 +108,10 @@ def reactivate!
103108
end
104109
end
105110

106-
update!(
107-
is_active: true,
108-
inactivated_at: nil
109-
)
111+
update!(inactivated_at: nil)
110112
end
111113

112-
# is_activeとinactivated_atの同期(移行期間中)
113-
before_save :sync_active_status
114-
115114
private
116-
117-
def sync_active_status
118-
if is_active_changed?
119-
if is_active == false && inactivated_at.nil?
120-
self.inactivated_at = Time.current
121-
elsif is_active == true && inactivated_at.present?
122-
# is_activeがtrueに変更された場合、inactivated_atをnilに
123-
self.inactivated_at = nil
124-
end
125-
end
126-
end
127115

128116
# Now 6+ tags are available since this PR:
129117
# https://github.com/coderdojo-japan/coderdojo.jp/pull/1697
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
# 現在は connpass と doorkeeper のみ対応しています。
2020
#
2121
# Facebook イベントなどを含む非対応のイベント情報については、
22-
# `db/static_event_histories.yaml` から手動でデータ入力が可能です。
23-
# https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/static_event_histories.yaml
22+
# `db/static_event_histories.yml` から手動でデータ入力が可能です。
23+
# https://github.com/coderdojo-japan/coderdojo.jp/blob/main/db/static_event_histories.yml
2424

2525

2626

2727
### 以下、Dojo 情報まとめ ###
28-
### (dojos.yaml の追加順) ###
28+
### (dojos.yml の追加順) ###
2929

3030
# 播磨科学公園都市(兵庫県上郡町)
3131
#- dojo_id: 343
@@ -34,7 +34,7 @@
3434
# url: https://codeclub.org/ja/clubs/1700a138-2909-4e4e-9e75-88ebcbbbc55a
3535

3636
# 砧(東京都世田谷区)- connpass の個人アカウントのため登録できない。グループアカウントにする必要がある。
37-
# TODO: グループ化されたら dojos.yamlのurlも合わせて更新
37+
# TODO: グループ化されたら dojos.ymlのurlも合わせて更新
3838
#- dojo_id: 342
3939
# name: connpass
4040
# group_id: ???

0 commit comments

Comments
 (0)