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:
parent
5214a14990
commit
d056a5e766
1 changed files with 11 additions and 2 deletions
|
@ -76,11 +76,20 @@ module NCMall
|
||||||
raise UnexpectedResponseFormat, "missing field object_data in NC page"
|
raise UnexpectedResponseFormat, "missing field object_data in NC page"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
object_data = nc_page["object_data"]
|
||||||
|
|
||||||
# NOTE: When there's no object data, it will be an empty array instead of
|
# NOTE: When there's no object data, it will be an empty array instead of
|
||||||
# an empty hash. Weird API thing to work around!
|
# 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"],
|
id: item_info["id"],
|
||||||
name: item_info["name"],
|
name: item_info["name"],
|
||||||
|
|
Loading…
Reference in a new issue