Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/card_cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

class CardCycle < ApplicationRecord
has_many :card_sets
# TODO(plural): Add association path for cycles -> printings
has_many :printings, :through => :card_sets
has_many :cards, :through => :printings
end
1 change: 1 addition & 0 deletions app/models/card_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class CardSet < ApplicationRecord
belongs_to :card_set_type

has_many :printings
has_many :cards, :through => :printings
end
1 change: 1 addition & 0 deletions app/models/faction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
class Faction < ApplicationRecord
belongs_to :side
has_many :cards
has_many :printings, :through => :cards
end
4 changes: 3 additions & 1 deletion app/models/printing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
class Printing < ApplicationRecord
belongs_to :card
belongs_to :card_set
# TODO(plural): Add an association to cycle.
has_one :faction, :through => :card
has_one :card_cycle, :through => :card_set
has_one :side, :through => :card
end
3 changes: 2 additions & 1 deletion app/models/side.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class Side < ApplicationRecord
has_many :cards
has_many :factions
has_many :cards
has_many :printings, :through => :cards
end
3 changes: 3 additions & 0 deletions app/resources/api/v3/public/card_cycle_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class Api::V3::Public::CardCycleResource < JSONAPI::Resource
key_type :string

has_many :card_sets
has_many :printings
has_many :cards

paginator :none
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/resources/api/v3/public/card_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class Api::V3::Public::CardResource < JSONAPI::Resource
attributes :stripped_title, :title, :card_type_id, :side_id, :faction_id, :advancement_requirement, :agenda_points, :base_link, :cost, :deck_limit, :influence_cost, :influence_limit, :memory_cost, :minimum_deck_size, :strength, :stripped_text, :text, :trash_cost, :is_unique, :display_subtypes, :updated_at
key_type :string

has_one :card_type
has_one :faction
has_one :side
has_one :faction
has_one :card_type
has_many :card_subtypes
has_many :printings
end
Expand Down
3 changes: 2 additions & 1 deletion app/resources/api/v3/public/card_set_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ module API
module V3
module Public
class Api::V3::Public::CardSetResource < JSONAPI::Resource
# TODO(plural): Add relationships in here.
attributes :name, :date_release, :size, :card_cycle_id, :card_set_type_id, :updated_at
key_type :string

paginator :none

has_one :card_cycle
has_one :card_set_type
has_many :printings
has_many :cards
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/resources/api/v3/public/faction_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Api::V3::Public::FactionResource < JSONAPI::Resource

paginator :none

has_one :side
has_many :cards
has_many :printings
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/resources/api/v3/public/printing_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ module API
module V3
module Public
class Api::V3::Public::PrintingResource < JSONAPI::Resource
# TODO: add relationships in here.
attributes :card_id, :card_set_id, :printed_text, :printed_is_unique, :flavor, :illustrator, :position, :quantity, :date_release, :updated_at
key_type :string

has_one :card_cycle
has_one :card_set
has_one :side
has_one :faction
has_one :card
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/resources/api/v3/public/side_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Api::V3::Public::SideResource < JSONAPI::Resource

paginator :none

has_many :factions
has_many :printings
has_many :cards
end
end
Expand Down