Dota 2 Wiki
Advertisement

Documentation for Module:Cargo Jump to code ↴ [ edit | purge ]

This module processes the output of Cargo queries. Empty values are removed and in case of no results, nil is returned instead of an empty table.

Performance

The module introduces some additional overhead leading to slightly worse performance. Raw mw.ext.cargo.query queries should be used where the automatic stripping of empty strings is not needed.

Module:Cargo mw.ext.cargo
Each call was running for about 3.6e-04 seconds.
    Mean runtime for each set was 3.6e-02 seconds,
    with standard deviation of 1.8e-03 seconds,
    minimum 6.0e-06, maximum 7.0e-06.
    Total time spent was about 3.6e-01 seconds.
Relative load is estimated to 5,579.6.
Each call was running for about 2.3e-04 seconds.
    Mean runtime for each set was 2.3e-02 seconds,
    with standard deviation of 1.6e-03 seconds,
    minimum 8.0e-06, maximum 1.0e-05.
    Total time spent was about 2.3e-01 seconds.
Relative load is estimated to 2,754.4.

Syntax

Main Article: Cargo documentation

The syntax is identical to the one provided by mw.ext.cargo.


local p = {}
local cargo = mw.ext.cargo


function p.query(tables, fields, arguments)
  local results = cargo.query(tables, fields, arguments)

  -- Remove results with empty strings from the results.
  local data = {}
  for i,result in ipairs(results) do
    data[i] = {}
    for k,v in pairs(result) do
      if v ~= '' then
        data[i][k] = v
      end
    end
  end

  return data
end


return p
Advertisement