Skip to content

Commit e28f9c6

Browse files
committed
Add num_printings attr to Illustrator and populate on import.
1 parent 4e92dd4 commit e28f9c6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Public
44
class Api::V3::Public::IllustratorResource < JSONAPI::Resource
55
immutable
66

7-
attributes :name, :updated_at
7+
attributes :name, :num_printings, :updated_at
88
key_type :string
99

1010
paginator :none

lib/tasks/cards.rake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ namespace :cards do
339339

340340
illustrators = Set[]
341341
illustrators_to_printings = []
342+
illustrator_num_printings = {}
342343
num_its = 0
343344
printings = Printing.all
344345
printings.each { |printing|
@@ -350,6 +351,10 @@ namespace :cards do
350351
"illustrator_id": text_to_id(i),
351352
"printing_id": printing.id
352353
}
354+
if !illustrator_num_printings.key?(i)
355+
illustrator_num_printings[i] = 0
356+
end
357+
illustrator_num_printings[i] += 1
353358
}
354359
end
355360
}
@@ -358,7 +363,8 @@ namespace :cards do
358363
illustrators.each { |i|
359364
ill << {
360365
"id": text_to_id(i),
361-
"name": i
366+
"name": i,
367+
"num_printings": illustrator_num_printings[i]
362368
}
363369
}
364370

0 commit comments

Comments
 (0)