File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 4
4
class SnapshotsController < ApplicationController
5
5
def index
6
6
add_total_stat ( params )
7
-
8
- base_scope = Snapshot . includes ( :card_pool , :cards , :restriction )
7
+ base_scope = Snapshot . includes ( :card_pool )
9
8
snapshots = SnapshotResource . all ( params , base_scope )
10
9
11
10
respond_with ( snapshots )
12
11
end
13
12
14
13
def show
15
- snapshot = SnapshotResource . find ( params )
14
+ base_scope = Snapshot . includes ( :card_pool )
15
+ snapshot = SnapshotResource . find ( params , base_scope )
16
16
respond_with ( snapshot )
17
17
end
18
18
end
Original file line number Diff line number Diff line change @@ -11,6 +11,6 @@ class Snapshot < ApplicationRecord
11
11
12
12
# TODO(plural): Convert date_start to a real date field.
13
13
def num_cards
14
- cards . length
14
+ cards . count
15
15
end
16
16
end
Original file line number Diff line number Diff line change 4
4
class SnapshotResource < ApplicationResource
5
5
primary_endpoint '/snapshots' , %i[ index show ]
6
6
7
+ self . default_page_size = 1000
8
+
7
9
attribute :id , :string
8
10
attribute :format_id , :string
9
11
attribute :active , :boolean
10
12
attribute :card_cycle_ids , :array_of_strings do
11
- @object . card_pool . card_pool_card_cycles . pluck ( :card_cycle_id )
13
+ @object . card_cycle_ids
12
14
end
13
15
attribute :card_set_ids , :array_of_strings do
14
- @object . card_pool . card_pool_card_sets . pluck ( :card_set_id )
16
+ @object . card_set_ids
15
17
end
16
18
attribute :card_pool_id , :string
17
19
attribute :restriction_id , :string
18
20
attribute :num_cards , :integer do
19
- @object . card_pool . cards . length
21
+ @object . card_pool . cards . count
20
22
end
21
23
attribute :date_start , :date
22
24
attribute :updated_at , :datetime
You can’t perform that action at this time.
0 commit comments