From d3b3a3060c3ec122ab7526fadb5e783743b85f75 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Tue, 14 May 2024 00:09:27 -0700 Subject: [PATCH] Split Item Getting Guide between NC Mall items and Other NC items This'll affect the recommended acquisition method by a lot! NC Mall info like current price isn't surfaced anywhere else in the app right now. It'd probably be good to add to the item page, and maybe some other places too! --- app/controllers/items_controller.rb | 5 +++-- app/models/item.rb | 5 +++++ app/views/items/sources.html.haml | 10 +++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index f41d3445..6f47ee54 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -114,14 +114,15 @@ class ItemsController < ApplicationController def sources item_ids = params[:ids].split(",") - @items = Item.where(id: item_ids).order(:name) + @items = Item.where(id: item_ids).includes(:nc_mall_record).order(:name) if @items.empty? render file: "public/404.html", status: :not_found, layout: nil return end - @nc_items = @items.select(&:nc?) + @nc_mall_items = @items.select(&:currently_in_mall?) + @other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?) @np_items = @items.select(&:np?) @pb_items = @items.select(&:pb?) diff --git a/app/models/item.rb b/app/models/item.rb index 6db92d53..49b9c3c9 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -8,6 +8,7 @@ class Item < ApplicationRecord has_many :closet_hangers has_one :contribution, :as => :contributed, :inverse_of => :contributed + has_one :nc_mall_record has_many :parent_swf_asset_relationships, :as => :parent has_many :swf_assets, :through => :parent_swf_asset_relationships @@ -162,6 +163,10 @@ class Item < ApplicationRecord !nc? && !pb? end + def currently_in_mall? + nc_mall_record.present? + end + def owned? @owned || false end diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index 0fe98f94..296c28d0 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -1,9 +1,9 @@ - title "Item Getting Guide" %h1#title Item Getting Guide -- if @nc_items.present? - %h2 Neocash items - = render @nc_items +- if @nc_mall_items.present? + %h2 NC Mall items + = render @nc_mall_items - if @np_items.present? %h2 Neopoint items @@ -12,3 +12,7 @@ - if @pb_items.present? %h2 Paintbrush items = render @pb_items + +- if @other_nc_items.present? + %h2 Other NC items + = render @other_nc_items