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
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ class UnauthorizedError < StandardError; end
register_exception BadDeckError, status: 400
register_exception UnauthorizedError, status: 403
register_exception UnauthorizedError, status: 403

def add_total_stat(params)
params['stats'] = {} unless params.include?('stats')
params['stats']['total'] = 'count'
end
end
1 change: 1 addition & 0 deletions app/controllers/card_cycles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the CardCycle resource.
class CardCyclesController < ApplicationController
def index
add_total_stat(params)
card_cycles = CardCycleResource.all(params)
respond_with(card_cycles)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/card_pools_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the CardPool resource.
class CardPoolsController < ApplicationController
def index
add_total_stat(params)
base_scope = CardPool.includes(:cards)
card_pools = CardPoolResource.all(params, base_scope)
respond_with(card_pools)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/card_set_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the CardSetType resource.
class CardSetTypesController < ApplicationController
def index
add_total_stat(params)
card_set_types = CardSetTypeResource.all(params)
respond_with(card_set_types)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/card_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the CardSet resource.
class CardSetsController < ApplicationController
def index
add_total_stat(params)
card_sets = CardSetResource.all(params)
respond_with(card_sets)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/card_subtypes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the CardSubtype resource.
class CardSubtypesController < ApplicationController
def index
add_total_stat(params)
card_subtypes = CardSubtypeResource.all(params)
respond_with(card_subtypes)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/card_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the CardType resource.
class CardTypesController < ApplicationController
def index
add_total_stat(params)
card_types = CardTypeResource.all(params)
respond_with(card_types)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/cards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Card resource.
class CardsController < ApplicationController
def index
add_total_stat(params)
cards = CardResource.all(params)
respond_with(cards)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/decklists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the decklist resource.
class DecklistsController < ApplicationController
def index
add_total_stat(params)
base_scope = Decklist.includes(:identity_card, :cards)
decklists = DecklistResource.all(params, base_scope)
respond_with(decklists)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/decks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class DecksController < ApplicationController
include JwtAuthorizationConcern

def index
add_total_stat(params)
base_scope = Deck.where(user_id: @current_user.id)
params[:filter].delete(:user_id) if params.include?(:filter)
decks = DeckResource.all(params, base_scope)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/factions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Faction resource.
class FactionsController < ApplicationController
def index
add_total_stat(params)
factions = FactionResource.all(params)
respond_with(factions)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/formats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Format resource.
class FormatsController < ApplicationController
def index
add_total_stat(params)
base_scope = Format.includes(:restrictions, :snapshots)
formats = FormatResource.all(params, base_scope)
respond_with(formats)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/illustrators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Illustrator resource.
class IllustratorsController < ApplicationController
def index
add_total_stat(params)
illustrators = IllustratorResource.all(params)
respond_with(illustrators)
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/printings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Printing resource.
class PrintingsController < ApplicationController
def index
add_total_stat(params)
printings = PrintingResource.all(params)

respond_with(printings)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/restrictions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Restriction resource.
class RestrictionsController < ApplicationController
def index
add_total_stat(params)
restrictions = RestrictionResource.all(params)

respond_with(restrictions)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Review resource.
class ReviewsController < ApplicationController
def index
add_total_stat(params)
base_scope = Review.includes(:card, :review_comments, :review_votes)
reviews = ReviewResource.all(params, base_scope)
respond_with(reviews)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/rulings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Ruling resource.
class RulingsController < ApplicationController
def index
add_total_stat(params)
rulings = RulingResource.all(params)

respond_with(rulings)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/sides_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Controller for the Side resource.
class SidesController < ApplicationController
def index
add_total_stat(params)
sides = SideResource.all(params)

respond_with(sides)
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/snapshots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Controller for the Snapshot resource.
class SnapshotsController < ApplicationController
def index
add_total_stat(params)

base_scope = Snapshot.includes(:card_pool, :cards, :restriction)
snapshots = SnapshotResource.all(params, base_scope)

Expand Down
2 changes: 1 addition & 1 deletion doc/api/card_cycles/all_card_cycles.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"request_content_type": "application/json",
"response_status": 200,
"response_status_text": "OK",
"response_body": "{\n \"data\": [\n {\n \"id\": \"core\",\n \"type\": \"card_cycles\",\n \"attributes\": {\n \"name\": \"Core Set\",\n \"date_release\": \"2012-09-06\",\n \"legacy_code\": \"core\",\n \"card_set_ids\": [\n \"core\"\n ],\n \"first_printing_id\": \"01050\",\n \"position\": null,\n \"released_by\": null,\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_cycle_id]=core\"\n }\n },\n \"printings\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/printings?filter[card_cycle_id]=core\"\n }\n },\n \"cards\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/cards?filter[card_cycle_id]=core\"\n }\n },\n \"card_pools\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_pools?filter[card_cycle_id]=core\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_cycles/core\"\n }\n },\n {\n \"id\": \"borealis\",\n \"type\": \"card_cycles\",\n \"attributes\": {\n \"name\": \"Borealis\",\n \"date_release\": \"2022-07-22\",\n \"legacy_code\": \"borealis\",\n \"card_set_ids\": [\n \"midnight_sun\",\n \"parhelion\"\n ],\n \"first_printing_id\": \"21166\",\n \"position\": null,\n \"released_by\": null,\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_cycle_id]=borealis\"\n }\n },\n \"printings\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/printings?filter[card_cycle_id]=borealis\"\n }\n },\n \"cards\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/cards?filter[card_cycle_id]=borealis\"\n }\n },\n \"card_pools\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_pools?filter[card_cycle_id]=borealis\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_cycles/borealis\"\n }\n }\n ],\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_cycles?page%5Bnumber%5D=1&page%5Bsize%5D=1000\",\n \"first\": \"http://localhost:3000/api/v3/public/card_cycles?page%5Bnumber%5D=1&page%5Bsize%5D=1000\",\n \"last\": \"http://localhost:3000/api/v3/public/card_cycles?page%5Bnumber%5D=1&page%5Bsize%5D=1000\"\n },\n \"meta\": {\n }\n}",
"response_body": "{\n \"data\": [\n {\n \"id\": \"core\",\n \"type\": \"card_cycles\",\n \"attributes\": {\n \"name\": \"Core Set\",\n \"date_release\": \"2012-09-06\",\n \"legacy_code\": \"core\",\n \"card_set_ids\": [\n \"core\"\n ],\n \"first_printing_id\": \"01050\",\n \"position\": null,\n \"released_by\": null,\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_cycle_id]=core\"\n }\n },\n \"printings\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/printings?filter[card_cycle_id]=core\"\n }\n },\n \"cards\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/cards?filter[card_cycle_id]=core\"\n }\n },\n \"card_pools\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_pools?filter[card_cycle_id]=core\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_cycles/core\"\n }\n },\n {\n \"id\": \"borealis\",\n \"type\": \"card_cycles\",\n \"attributes\": {\n \"name\": \"Borealis\",\n \"date_release\": \"2022-07-22\",\n \"legacy_code\": \"borealis\",\n \"card_set_ids\": [\n \"midnight_sun\",\n \"parhelion\"\n ],\n \"first_printing_id\": \"21166\",\n \"position\": null,\n \"released_by\": null,\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_cycle_id]=borealis\"\n }\n },\n \"printings\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/printings?filter[card_cycle_id]=borealis\"\n }\n },\n \"cards\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/cards?filter[card_cycle_id]=borealis\"\n }\n },\n \"card_pools\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_pools?filter[card_cycle_id]=borealis\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_cycles/borealis\"\n }\n }\n ],\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_cycles?page%5Bnumber%5D=1&page%5Bsize%5D=1000&stats%5Btotal%5D=count\",\n \"first\": \"http://localhost:3000/api/v3/public/card_cycles?page%5Bnumber%5D=1&page%5Bsize%5D=1000&stats%5Btotal%5D=count\",\n \"last\": \"http://localhost:3000/api/v3/public/card_cycles?page%5Bnumber%5D=1&page%5Bsize%5D=1000&stats%5Btotal%5D=count\"\n },\n \"meta\": {\n \"stats\": {\n \"total\": {\n \"count\": 2\n }\n }\n }\n}",
"response_headers": {
"Content-Type": "application/vnd.api+json; charset=utf-8"
},
Expand Down
2 changes: 1 addition & 1 deletion doc/api/card_pools/all_card_pools.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/api/card_set_types/all_card_set_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"request_content_type": "application/json",
"response_status": 200,
"response_status_text": "OK",
"response_body": "{\n \"data\": [\n {\n \"id\": \"core\",\n \"type\": \"card_set_types\",\n \"attributes\": {\n \"name\": \"Core\",\n \"description\": \"A core set, or set that makes up part of the core selection of cards.\",\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_set_type_id]=core\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_set_types/core\"\n }\n },\n {\n \"id\": \"booster_pack\",\n \"type\": \"card_set_types\",\n \"attributes\": {\n \"name\": \"Booster Pack\",\n \"description\": \"A booster pack released as a subset of a larger release.\",\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_set_type_id]=booster_pack\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_set_types/booster_pack\"\n }\n }\n ],\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_set_types?page%5Bnumber%5D=1&page%5Bsize%5D=20\",\n \"first\": \"http://localhost:3000/api/v3/public/card_set_types?page%5Bnumber%5D=1&page%5Bsize%5D=20\",\n \"last\": \"http://localhost:3000/api/v3/public/card_set_types?page%5Bnumber%5D=1&page%5Bsize%5D=20\"\n },\n \"meta\": {\n }\n}",
"response_body": "{\n \"data\": [\n {\n \"id\": \"core\",\n \"type\": \"card_set_types\",\n \"attributes\": {\n \"name\": \"Core\",\n \"description\": \"A core set, or set that makes up part of the core selection of cards.\",\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_set_type_id]=core\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_set_types/core\"\n }\n },\n {\n \"id\": \"booster_pack\",\n \"type\": \"card_set_types\",\n \"attributes\": {\n \"name\": \"Booster Pack\",\n \"description\": \"A booster pack released as a subset of a larger release.\",\n \"updated_at\": \"2022-12-08T12:00:00+00:00\"\n },\n \"relationships\": {\n \"card_sets\": {\n \"links\": {\n \"related\": \"http://localhost:3000/api/v3/public/card_sets?filter[card_set_type_id]=booster_pack\"\n }\n }\n },\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_set_types/booster_pack\"\n }\n }\n ],\n \"links\": {\n \"self\": \"http://localhost:3000/api/v3/public/card_set_types?page%5Bnumber%5D=1&page%5Bsize%5D=20&stats%5Btotal%5D=count\",\n \"first\": \"http://localhost:3000/api/v3/public/card_set_types?page%5Bnumber%5D=1&page%5Bsize%5D=20&stats%5Btotal%5D=count\",\n \"last\": \"http://localhost:3000/api/v3/public/card_set_types?page%5Bnumber%5D=1&page%5Bsize%5D=20&stats%5Btotal%5D=count\"\n },\n \"meta\": {\n \"stats\": {\n \"total\": {\n \"count\": 2\n }\n }\n }\n}",
"response_headers": {
"Content-Type": "application/vnd.api+json; charset=utf-8"
},
Expand Down
Loading