Module:Store locations list: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 67: Line 67:


     -- Create the rows for the output table
     -- Create the rows for the output table
     for _, shop in ipairs(data) do
     for _, shop in ipairs(data) do  
    mw.log("shop", inspect(shop))
   
     for i, location in ipairs(shop.location) do
     for i, location in ipairs(shop.location) do
        addShopRow(shop, location)
        addShopRow(shop, location)
Line 115: Line 113:
     end
     end
     mw.log(string.format('SMW (store locations list): entries: %d, time elapsed: %.3f ms.', #smwdata, (t2 - t1) * 1000))
     mw.log(string.format('SMW (store locations list): entries: %d, time elapsed: %.3f ms.', #smwdata, (t2 - t1) * 1000))
   
    mw.log("smw data", inspect(smwdata))


     table.sort(smwdata, function(a, b) return b['Store sell price'] < a['Store sell price'] end)
     table.sort(smwdata, function(a, b) return b['Store sell price'] < a['Store sell price'] end)
Line 129: Line 125:
             table.insert(members, item['Is members only'])
             table.insert(members, item['Is members only'])
elseif type(item['Is members only']) == 'string' then
elseif type(item['Is members only']) == 'string' then
mw.log("members only string")
             table.insert(members, item['Members'])
             table.insert(members, item['Members'])
         end
         end
Line 150: Line 145:
         -- item['Region'] = region
         -- item['Region'] = region


mw.log("#members", #members)
mw.log("members", members)
       
         if #members == 1 then
         if #members == 1 then
Line 166: Line 158:
         -- Process the item and add it to the final data table
         -- Process the item and add it to the final data table
         local dataline = p.processData(item, editbtn)
         local dataline = p.processData(item, editbtn)
mw.log("dataline", inspect(dataline))


         table.insert(data, dataline)
         table.insert(data, dataline)
Line 243: Line 233:
     -- members only?
     -- members only?
     local members = item['Members']
     local members = item['Members']
mw.log("item", inspect(item))


mw.log("members", members)
mw.log("members dump", inspect(members))
     if type(members) == 'table' then
     if type(members) == 'table' then
         -- contains yes and/or no
         -- contains yes and/or no
Line 274: Line 260:
         members = editbtn
         members = editbtn
     end
     end
mw.log("final members", members)


     return {
     return {

Navigation menu