Skip to content

Commit ddc5775

Browse files
authored
Merge pull request #68 from plural/add-cards-and-format-id-to-snapshot-resource
Add cards relation and format_id attribute to snapshot resource.
2 parents 69a7196 + 89c3263 commit ddc5775

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app/models/snapshot.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ class Snapshot < ApplicationRecord
44
belongs_to :format
55
belongs_to :card_pool
66
belongs_to :restriction, optional: :true
7+
has_many :cards, through: :card_pool
78
end

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ module Public
44
class Api::V3::Public::SnapshotResource < JSONAPI::Resource
55
immutable
66

7-
attributes :active, :card_cycle_ids, :card_set_ids, :date_start, :updated_at
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
13-
# has_one :card_pool
13+
has_one :card_pool
1414
has_one :restriction
1515

16+
has_many :cards
17+
1618
def card_cycle_ids
1719
@model.card_pool.card_pool_card_cycles.pluck(:card_cycle_id)
1820
end

0 commit comments

Comments
 (0)