Skip to content

Commit 6f188ac

Browse files
authored
Merge pull request #141 from plural/illustrator-num-printings
Illustrator num printings
2 parents c7f74c8 + a3912e9 commit 6f188ac

File tree

8 files changed

+22
-7
lines changed

8 files changed

+22
-7
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
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddNumPrintingsToIllustrators < ActiveRecord::Migration[7.0]
2+
def change
3+
add_column :illustrators, :num_printings, :integer
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2022_11_25_065640) do
13+
ActiveRecord::Schema[7.0].define(version: 2022_11_25_223355) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

@@ -148,6 +148,7 @@
148148
t.string "name"
149149
t.datetime "created_at", null: false
150150
t.datetime "updated_at", null: false
151+
t.integer "num_printings"
151152
end
152153

153154
create_table "illustrators_printings", id: false, force: :cascade do |t|

doc/api/illustrators/all_illustrators.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"request_content_type": "application/json",
2626
"response_status": 200,
2727
"response_status_text": "OK",
28-
"response_body": "{\n \"data\": [\n {\n \"id\": \"ann_illustrator\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator\"\n },\n \"attributes\": {\n \"name\": \"Ann Illustrator\",\n \"updated_at\": \"2022-11-25T07:06:27.064Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/printings\"\n }\n }\n }\n },\n {\n \"id\": \"good_drawers\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/good_drawers\"\n },\n \"attributes\": {\n \"name\": \"Good Drawers\",\n \"updated_at\": \"2022-11-25T07:06:27.064Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/good_drawers/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/good_drawers/printings\"\n }\n }\n }\n },\n {\n \"id\": \"tom_of_netrunner\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner\"\n },\n \"attributes\": {\n \"name\": \"Tom of Netrunner\",\n \"updated_at\": \"2022-11-25T07:06:27.064Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/printings\"\n }\n }\n }\n }\n ]\n}",
28+
"response_body": "{\n \"data\": [\n {\n \"id\": \"ann_illustrator\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator\"\n },\n \"attributes\": {\n \"name\": \"Ann Illustrator\",\n \"num_printings\": 1,\n \"updated_at\": \"2022-11-25T22:52:21.616Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/printings\"\n }\n }\n }\n },\n {\n \"id\": \"good_drawers\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/good_drawers\"\n },\n \"attributes\": {\n \"name\": \"Good Drawers\",\n \"num_printings\": 1,\n \"updated_at\": \"2022-11-25T22:52:21.616Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/good_drawers/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/good_drawers/printings\"\n }\n }\n }\n },\n {\n \"id\": \"tom_of_netrunner\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner\"\n },\n \"attributes\": {\n \"name\": \"Tom of Netrunner\",\n \"num_printings\": 1,\n \"updated_at\": \"2022-11-25T22:52:21.616Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/printings\"\n }\n }\n }\n }\n ]\n}",
2929
"response_headers": {
3030
"Content-Type": "application/vnd.api+json"
3131
},

doc/api/illustrators/get_a_single_illustrator.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"request_content_type": "application/json",
3131
"response_status": 200,
3232
"response_status_text": "OK",
33-
"response_body": "{\n \"data\": {\n \"id\": \"ann_illustrator\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator\"\n },\n \"attributes\": {\n \"name\": \"Ann Illustrator\",\n \"updated_at\": \"2022-11-25T07:06:27.064Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/printings\"\n }\n }\n }\n }\n}",
33+
"response_body": "{\n \"data\": {\n \"id\": \"ann_illustrator\",\n \"type\": \"illustrators\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator\"\n },\n \"attributes\": {\n \"name\": \"Ann Illustrator\",\n \"num_printings\": 1,\n \"updated_at\": \"2022-11-25T22:52:21.616Z\"\n },\n \"relationships\": {\n \"printings\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/relationships/printings\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/ann_illustrator/printings\"\n }\n }\n }\n }\n}",
3434
"response_headers": {
3535
"Content-Type": "application/vnd.api+json"
3636
},

doc/api/illustrators/relationship_-_get_printings_for_an_illustrator.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"request_content_type": "application/json",
3131
"response_status": 200,
3232
"response_status_text": "OK",
33-
"response_body": "{\n \"data\": [\n {\n \"id\": \"01056\",\n \"type\": \"printings\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056\"\n },\n \"attributes\": {\n \"card_id\": \"adonis_campaign\",\n \"card_cycle_id\": \"core\",\n \"card_cycle_name\": \"Core Set\",\n \"card_set_id\": \"core\",\n \"card_set_name\": \"Core\",\n \"printed_text\": \"Gain Money at the start of your turn\",\n \"stripped_printed_text\": \"Gain Money at the start of your turn\",\n \"printed_is_unique\": false,\n \"flavor\": \"Beefy Boi\",\n \"display_illustrators\": \"Tom of Netrunner\",\n \"illustrator_ids\": [\n \"tom_of_netrunner\"\n ],\n \"illustrator_names\": [\n \"Tom of Netrunner\"\n ],\n \"position\": 56,\n \"quantity\": 3,\n \"date_release\": \"2012-09-06\",\n \"updated_at\": \"2022-11-25T07:06:27.065Z\",\n \"advancement_requirement\": null,\n \"agenda_points\": null,\n \"base_link\": null,\n \"card_type_id\": \"asset\",\n \"cost\": null,\n \"deck_limit\": null,\n \"display_subtypes\": null,\n \"card_subtype_ids\": [\n \"advertisement\"\n ],\n \"card_subtype_names\": [\n \"Advertisement\"\n ],\n \"faction_id\": \"haas_bioroid\",\n \"influence_cost\": null,\n \"influence_limit\": null,\n \"is_unique\": null,\n \"memory_cost\": null,\n \"minimum_deck_size\": null,\n \"side_id\": \"corp\",\n \"strength\": null,\n \"stripped_text\": null,\n \"stripped_title\": \"Adonis Campaign\",\n \"text\": null,\n \"title\": \"Adonis Campaign\",\n \"trash_cost\": null,\n \"printing_ids\": [\n \"01056\"\n ],\n \"num_printings\": 1,\n \"restriction_ids\": [\n\n ],\n \"in_restriction\": false,\n \"format_ids\": [\n\n ],\n \"card_pool_ids\": [\n\n ],\n \"snapshot_ids\": [\n\n ],\n \"attribution\": null,\n \"card_abilities\": {\n \"additional_cost\": false,\n \"advanceable\": false,\n \"gains_subroutines\": false,\n \"interrupt\": false,\n \"link_provided\": null,\n \"mu_provided\": null,\n \"num_printed_subroutines\": null,\n \"on_encounter_effect\": false,\n \"performs_trace\": false,\n \"recurring_credits_provided\": null,\n \"rez_effect\": false,\n \"trash_ability\": false\n },\n \"images\": {\n \"nrdb_classic\": {\n \"tiny\": \"https://static.nrdbassets.com/v1/tiny/01056.jpg\",\n \"small\": \"https://static.nrdbassets.com/v1/small/01056.jpg\",\n \"medium\": \"https://static.nrdbassets.com/v1/medium/01056.jpg\",\n \"large\": \"https://static.nrdbassets.com/v1/large/01056.jpg\"\n }\n },\n \"latest_printing_id\": \"01056\",\n \"restrictions\": {\n \"banned\": [\n\n ],\n \"global_penalty\": [\n\n ],\n \"points\": {\n },\n \"restricted\": [\n\n ],\n \"universal_faction_cost\": {\n }\n }\n },\n \"relationships\": {\n \"card\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/card\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/card\"\n }\n },\n \"card_cycle\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/card_cycle\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/card_cycle\"\n }\n },\n \"card_set\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/card_set\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/card_set\"\n }\n },\n \"faction\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/faction\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/faction\"\n }\n },\n \"illustrators\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/illustrators\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/illustrators\"\n }\n },\n \"side\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/side\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/side\"\n }\n }\n }\n }\n ],\n \"links\": {\n \"first\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/printings?page%5Blimit%5D=100&page%5Boffset%5D=0\",\n \"last\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/printings?page%5Blimit%5D=100&page%5Boffset%5D=0\"\n }\n}",
33+
"response_body": "{\n \"data\": [\n {\n \"id\": \"01056\",\n \"type\": \"printings\",\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056\"\n },\n \"attributes\": {\n \"card_id\": \"adonis_campaign\",\n \"card_cycle_id\": \"core\",\n \"card_cycle_name\": \"Core Set\",\n \"card_set_id\": \"core\",\n \"card_set_name\": \"Core\",\n \"printed_text\": \"Gain Money at the start of your turn\",\n \"stripped_printed_text\": \"Gain Money at the start of your turn\",\n \"printed_is_unique\": false,\n \"flavor\": \"Beefy Boi\",\n \"display_illustrators\": \"Tom of Netrunner\",\n \"illustrator_ids\": [\n \"tom_of_netrunner\"\n ],\n \"illustrator_names\": [\n \"Tom of Netrunner\"\n ],\n \"position\": 56,\n \"quantity\": 3,\n \"date_release\": \"2012-09-06\",\n \"updated_at\": \"2022-11-25T22:52:21.617Z\",\n \"advancement_requirement\": null,\n \"agenda_points\": null,\n \"base_link\": null,\n \"card_type_id\": \"asset\",\n \"cost\": null,\n \"deck_limit\": null,\n \"display_subtypes\": null,\n \"card_subtype_ids\": [\n \"advertisement\"\n ],\n \"card_subtype_names\": [\n \"Advertisement\"\n ],\n \"faction_id\": \"haas_bioroid\",\n \"influence_cost\": null,\n \"influence_limit\": null,\n \"is_unique\": null,\n \"memory_cost\": null,\n \"minimum_deck_size\": null,\n \"side_id\": \"corp\",\n \"strength\": null,\n \"stripped_text\": null,\n \"stripped_title\": \"Adonis Campaign\",\n \"text\": null,\n \"title\": \"Adonis Campaign\",\n \"trash_cost\": null,\n \"printing_ids\": [\n \"01056\"\n ],\n \"num_printings\": 1,\n \"restriction_ids\": [\n\n ],\n \"in_restriction\": false,\n \"format_ids\": [\n\n ],\n \"card_pool_ids\": [\n\n ],\n \"snapshot_ids\": [\n\n ],\n \"attribution\": null,\n \"card_abilities\": {\n \"additional_cost\": false,\n \"advanceable\": false,\n \"gains_subroutines\": false,\n \"interrupt\": false,\n \"link_provided\": null,\n \"mu_provided\": null,\n \"num_printed_subroutines\": null,\n \"on_encounter_effect\": false,\n \"performs_trace\": false,\n \"recurring_credits_provided\": null,\n \"rez_effect\": false,\n \"trash_ability\": false\n },\n \"images\": {\n \"nrdb_classic\": {\n \"tiny\": \"https://static.nrdbassets.com/v1/tiny/01056.jpg\",\n \"small\": \"https://static.nrdbassets.com/v1/small/01056.jpg\",\n \"medium\": \"https://static.nrdbassets.com/v1/medium/01056.jpg\",\n \"large\": \"https://static.nrdbassets.com/v1/large/01056.jpg\"\n }\n },\n \"latest_printing_id\": \"01056\",\n \"restrictions\": {\n \"banned\": [\n\n ],\n \"global_penalty\": [\n\n ],\n \"points\": {\n },\n \"restricted\": [\n\n ],\n \"universal_faction_cost\": {\n }\n }\n },\n \"relationships\": {\n \"card\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/card\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/card\"\n }\n },\n \"card_cycle\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/card_cycle\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/card_cycle\"\n }\n },\n \"card_set\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/card_set\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/card_set\"\n }\n },\n \"faction\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/faction\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/faction\"\n }\n },\n \"illustrators\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/illustrators\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/illustrators\"\n }\n },\n \"side\": {\n \"links\": {\n \"self\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/relationships/side\",\n \"related\": \"http://api-preview.netrunnerdb.com/api/v3/public/printings/01056/side\"\n }\n }\n }\n }\n ],\n \"links\": {\n \"first\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/printings?page%5Blimit%5D=100&page%5Boffset%5D=0\",\n \"last\": \"http://api-preview.netrunnerdb.com/api/v3/public/illustrators/tom_of_netrunner/printings?page%5Blimit%5D=100&page%5Boffset%5D=0\"\n }\n}",
3434
"response_headers": {
3535
"Content-Type": "application/vnd.api+json"
3636
},

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

test/fixtures/illustrators.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
good_drawers:
22
id: good_drawers
33
name: "Good Drawers"
4+
num_printings: 1
45

56
ann_illustrator:
67
id: ann_illustrator
78
name: "Ann Illustrator"
9+
num_printings: 1
810

911
tom_of_netrunner:
1012
id: tom_of_netrunner
11-
name: "Tom of Netrunner"
13+
name: "Tom of Netrunner"
14+
num_printings: 1

0 commit comments

Comments
 (0)