Oops, don't show not-directly-for-sale items as being "0 NC"

"Fall Woodland Leaves Filter" is an example, it's part of the two-item
*pack* named "Fall Woodland Minitheus Petpet Foreground". The NC Mall
page for it will include the secondary items in `object_data`, but it's
not part of the storefront itself—and the only thing indicating that is
the `render` list.

Theoretically, we could use this to construct more data about like,
packs and stuff, automatically? But also, I don't want to backfill it
for everything historically, so like. Whatever.
This commit is contained in:
Emi Matchu 2024-09-27 18:27:12 -07:00
parent 5214a14990
commit d056a5e766

View file

@ -76,11 +76,20 @@ module NCMall
raise UnexpectedResponseFormat, "missing field object_data in NC page"
end
object_data = nc_page["object_data"]
# NOTE: When there's no object data, it will be an empty array instead of
# an empty hash. Weird API thing to work around!
nc_page["object_data"] = {} if nc_page["object_data"] == []
object_data = {} if object_data == []
items = nc_page["object_data"].values.map do |item_info|
# Only the items in the `render` list are actually listed as directly for
# sale in the shop. `object_data` might contain other items that provide
# supporting information about them, but aren't actually for sale.
visible_object_data = (nc_page["render"] || []).
map { |id| object_data[id.to_s] }.
filter(&:present?)
items = visible_object_data.map do |item_info|
{
id: item_info["id"],
name: item_info["name"],