Skip to content

Commit 89c3263

Browse files
committed
Merge branch 'main' into add-cards-and-format-id-to-snapshot-resource
2 parents 50664d1 + 69a7196 commit 89c3263

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

app/resources/api/v3/public/format_resource.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ class Api::V3::Public::FormatResource < JSONAPI::Resource
99

1010
paginator :none
1111

12-
has_many :snapshots
1312
has_many :card_pools
13+
has_many :restrictions
14+
has_many :snapshots
1415
end
1516
end
1617
end

app/resources/api/v3/public/snapshot_resource.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ module V3
33
module Public
44
class Api::V3::Public::SnapshotResource < JSONAPI::Resource
55
immutable
6-
7-
attributes :format_id, :active, :date_start, :updated_at
6+
7+
attributes :format_id, :active, :card_cycle_ids, :card_set_ids, :date_start, :updated_at
88
key_type :string
99

1010
paginator :none
1111

1212
belongs_to :format
1313
has_one :card_pool
1414
has_one :restriction
15+
1516
has_many :cards
17+
18+
def card_cycle_ids
19+
@model.card_pool.card_pool_card_cycles.pluck(:card_cycle_id)
20+
end
21+
22+
def card_set_ids
23+
@model.card_pool.card_pool_card_sets.pluck(:card_set_id)
24+
end
1625
end
1726
end
1827
end

lib/tasks/cards.rake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ namespace :cards do
310310

311311
# Collect each card pool's cycles
312312
card_pools.each do |p|
313-
next if p['cycles'].nil?
314-
p['cycles'].each do |s|
313+
next if p['card_cycle_ids'].nil?
314+
p['card_cycle_ids'].each do |s|
315315
card_pool_id_to_cycle_id << [p['id'], s]
316316
end
317317
end
@@ -353,8 +353,8 @@ namespace :cards do
353353

354354
# Collect each card pool's sets
355355
card_pools.each do |p|
356-
next if p['packs'].nil?
357-
p['packs'].each do |s|
356+
next if p['card_set_ids'].nil?
357+
p['card_set_ids'].each do |s|
358358
card_pool_id_to_set_id << [p['id'], s]
359359
end
360360
end

0 commit comments

Comments
 (0)