From 2f05d6597957ef14ac86441bd66d2e54bc36d52e Mon Sep 17 00:00:00 2001 From: Miguel de los Reyes Date: Mon, 23 Jun 2025 23:29:25 +0000 Subject: [PATCH 1/2] Add latest_printing_images field --- app/resources/card_resource.rb | 3 +++ spec/resources/card_resource_reads_spec.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/resources/card_resource.rb b/app/resources/card_resource.rb index a26ee22..298845d 100644 --- a/app/resources/card_resource.rb +++ b/app/resources/card_resource.rb @@ -92,6 +92,9 @@ class CardResource < ApplicationResource # rubocop:disable Metrics/ClassLength attribute :card_abilities, :hash attribute :restrictions, :hash attribute :latest_printing_id, :string + attribute :latest_printing_images, :hash do + images(@object.latest_printing_id) + end filter :card_cycle_id, :string do eq do |scope, value| diff --git a/spec/resources/card_resource_reads_spec.rb b/spec/resources/card_resource_reads_spec.rb index 69eacf8..e2e5983 100644 --- a/spec/resources/card_resource_reads_spec.rb +++ b/spec/resources/card_resource_reads_spec.rb @@ -34,6 +34,8 @@ expect(data.influence_limit).to eq(card.influence_limit) expect(data.is_unique).to eq(card.is_unique) expect(data.latest_printing_id).to eq(card.latest_printing_id) + expect(data.latest_printing_images).not_to be_nil + expect(data.latest_printing_images['nrdb_classic']).to include('tiny', 'small', 'medium', 'large') expect(data.memory_cost).to eq(card.memory_cost) expect(data.minimum_deck_size).to eq(card.minimum_deck_size) expect(data.num_printings).to eq(card.num_printings) From c7dd13d2878d03d14b75da53c9bd99fc9080904e Mon Sep 17 00:00:00 2001 From: Miguel de los Reyes Date: Tue, 24 Jun 2025 00:10:28 +0000 Subject: [PATCH 2/2] Add missing images function --- app/resources/card_resource.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/resources/card_resource.rb b/app/resources/card_resource.rb index 298845d..c608ebb 100644 --- a/app/resources/card_resource.rb +++ b/app/resources/card_resource.rb @@ -160,4 +160,20 @@ class CardResource < ApplicationResource # rubocop:disable Metrics/ClassLength end many_to_many :card_pools + + private + + def images(id, face_index = nil) + url_prefix = Rails.configuration.x.printing_images.nrdb_classic_prefix + face_suffix = "-#{face_index}" unless face_index.nil? + { + 'nrdb_classic' => { + 'tiny' => "#{url_prefix}/tiny/#{id}#{face_suffix}.jpg", + 'small' => "#{url_prefix}/small/#{id}#{face_suffix}.jpg", + 'medium' => "#{url_prefix}/medium/#{id}#{face_suffix}.jpg", + 'large' => "#{url_prefix}/large/#{id}#{face_suffix}.jpg", + 'narrative' => "#{url_prefix}/large/#{id}#{face_suffix}-narrative.jpg" + } + } + end end