local Luan = require "luan:Luan.luan" local error = Luan.error local pairs = Luan.pairs or error() local ipairs = Luan.ipairs or error() local type = Luan.type or error() local String = require "luan:String.luan" local format = String.format or error() local Number = require "luan:Number.luan" local float = Number.float or error() local Table = require "luan:Table.luan" local concat = Table.concat or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local get_data = require "site:/private/lib/get_data.luan" local Pricing = require "site:/private/lib/Pricing.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "discontinued_sizes.html" local is_production = Http.domain == "data.tleggings.com" local data = get_data(is_production) local products = data.products or error() local colors = data.colors or error() local base_url = is_production and "https://www.tleggings.com" or "http://test.tleggings.com" return function() Io.stdout = Http.response.text_writer() %> <% for name, product in pairs(products) do if product.discontinued == true then continue end local code = product.factory_code if type(code) == "table" then code = concat(code,"/") end for color_name, color_info in pairs(product.colors) do if color_info.discontinued == true then continue end local title = color_info.pattern and color_info.pattern.title or colors[color_name].title for _, size in ipairs(color_info.discontinued_sizes or {}) do %> <% end end end %>
dir title factory code color color title size
<%=name%> <%=product.title%> <%= product.factory %> <%= code %> <%= color_name %> <%= title %> <%= size %>
<% end