<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://skullgirls.cn/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3ACargo</id>
	<title>模块:Cargo - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://skullgirls.cn/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3ACargo"/>
	<link rel="alternate" type="text/html" href="https://skullgirls.cn/index.php?title=%E6%A8%A1%E5%9D%97:Cargo&amp;action=history"/>
	<updated>2026-05-06T13:07:54Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://skullgirls.cn/index.php?title=%E6%A8%A1%E5%9D%97:Cargo&amp;diff=1321&amp;oldid=prev</id>
		<title>2025年1月10日 (五) 16:27 圈圈菌Q</title>
		<link rel="alternate" type="text/html" href="https://skullgirls.cn/index.php?title=%E6%A8%A1%E5%9D%97:Cargo&amp;diff=1321&amp;oldid=prev"/>
		<updated>2025-01-10T16:27:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://skullgirls.cn/index.php?title=%E6%A8%A1%E5%9D%97:Cargo&amp;amp;diff=1321&amp;amp;oldid=1320&quot;&gt;显示更改&lt;/a&gt;</summary>
		<author><name>圈圈菌Q</name></author>
	</entry>
	<entry>
		<id>https://skullgirls.cn/index.php?title=%E6%A8%A1%E5%9D%97:Cargo&amp;diff=1320&amp;oldid=prev</id>
		<title>圈圈菌Q：​创建页面，内容为“local cargo = {} local extCargo = mw.ext.cargo local checkType = require( &#039;libraryUtil&#039; ).checkType local mArguments local cache = {}   --- Flatten key value pairs table into string --- --- @param t table Table to be flatten --- @return string local function flattenTableToString( t ) 	local stringTable = {} 	for k, v in pairs( t ) do 		table.insert( stringTable, string.format( &#039;%s:%s&#039;, k, v ) ) 	end 	return table.concat( stringTable, &#039;,&#039; ) end   --- Format resu…”</title>
		<link rel="alternate" type="text/html" href="https://skullgirls.cn/index.php?title=%E6%A8%A1%E5%9D%97:Cargo&amp;diff=1320&amp;oldid=prev"/>
		<updated>2025-01-10T13:40:21Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“local cargo = {} local extCargo = mw.ext.cargo local checkType = require( &amp;#039;libraryUtil&amp;#039; ).checkType local mArguments local cache = {}   --- Flatten key value pairs table into string --- --- @param t table Table to be flatten --- @return string local function flattenTableToString( t ) 	local stringTable = {} 	for k, v in pairs( t ) do 		table.insert( stringTable, string.format( &amp;#039;%s:%s&amp;#039;, k, v ) ) 	end 	return table.concat( stringTable, &amp;#039;,&amp;#039; ) end   --- Format resu…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local cargo = {}&lt;br /&gt;
local extCargo = mw.ext.cargo&lt;br /&gt;
local checkType = require( &amp;#039;libraryUtil&amp;#039; ).checkType&lt;br /&gt;
local mArguments&lt;br /&gt;
local cache = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Flatten key value pairs table into string&lt;br /&gt;
---&lt;br /&gt;
--- @param t table Table to be flatten&lt;br /&gt;
--- @return string&lt;br /&gt;
local function flattenTableToString( t )&lt;br /&gt;
	local stringTable = {}&lt;br /&gt;
	for k, v in pairs( t ) do&lt;br /&gt;
		table.insert( stringTable, string.format( &amp;#039;%s:%s&amp;#039;, k, v ) )&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat( stringTable, &amp;#039;,&amp;#039; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Format results from Cargo query into wikitext for output&lt;br /&gt;
---&lt;br /&gt;
--- @param results table Results from Cargo query&lt;br /&gt;
--- @param format string Format for the Cargo query&lt;br /&gt;
--- @return string&lt;br /&gt;
local function formatQueryResultsToWikitext( results, format )&lt;br /&gt;
	if format == &amp;#039;debug&amp;#039; then&lt;br /&gt;
		return &amp;#039;&amp;lt;pre&amp;gt;&amp;#039; .. mw.dumpObject( results ) .. &amp;#039;&amp;lt;/pre&amp;gt;&amp;#039;&lt;br /&gt;
	-- Default to table output&lt;br /&gt;
	else&lt;br /&gt;
		local table = mw.html.create( &amp;#039;table&amp;#039; ):addClass( &amp;#039;wikitable&amp;#039; )&lt;br /&gt;
		local headerRow = mw.html.create( &amp;#039;tr&amp;#039; )&lt;br /&gt;
		table:node( headerRow )&lt;br /&gt;
&lt;br /&gt;
		for i, result in pairs( results ) do&lt;br /&gt;
			local bodyRow = mw.html.create( &amp;#039;tr&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
			for k, v in pairs( result ) do&lt;br /&gt;
				if i == 1 then&lt;br /&gt;
					headerRow:tag( &amp;#039;th&amp;#039; ):wikitext( k )&lt;br /&gt;
				end&lt;br /&gt;
				bodyRow:tag( &amp;#039;td&amp;#039; ):wikitext( v )&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			table:node( bodyRow )&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		return tostring( table )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Cache Cargo query result&lt;br /&gt;
--- TODO: Make it smarter so that it separate the tables and fields into different caches&lt;br /&gt;
---&lt;br /&gt;
--- @param results table Results from Cargo query&lt;br /&gt;
--- @param tables string Tables param from Cargo query&lt;br /&gt;
--- @param fields string Fields param from Cargo query&lt;br /&gt;
--- @param argsString string Flatten args param from Cargo query&lt;br /&gt;
local function cacheQueryResults( results, tables, fields, argsString )&lt;br /&gt;
	-- Init index&lt;br /&gt;
	if not cache[ tables ] then&lt;br /&gt;
		cache[ tables ] = {}&lt;br /&gt;
	end&lt;br /&gt;
	if not cache[ tables ][ fields ] then&lt;br /&gt;
		cache[ tables ][ fields ] = {}&lt;br /&gt;
	end&lt;br /&gt;
	if not cache[ tables ][ fields ][ argsString ] then&lt;br /&gt;
		cache[ tables ][ fields ][ argsString ] = {}&lt;br /&gt;
	end&lt;br /&gt;
	-- mw.log( string.format( &amp;#039;[Cargo] Cached Cargo query result at: cache[\&amp;#039;%s\&amp;#039;][\&amp;#039;%s\&amp;#039;][\&amp;#039;%s\&amp;#039;]&amp;#039;, tables, fields, argsString ) )&lt;br /&gt;
	cache[ tables ][ fields ][ argsString ] = results&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Return the result of a Cargo query (#cargo_query)&lt;br /&gt;
---&lt;br /&gt;
--- For info on the parameters:&lt;br /&gt;
--- @see https://www.mediawiki.org/wiki/Extension:Cargo/Other_features#Lua_support&lt;br /&gt;
---&lt;br /&gt;
--- @param tables string The set of Cargo tables to be queried&lt;br /&gt;
--- @param fields string The field or set of fields to be displayed&lt;br /&gt;
--- @param args table Optional parameters for the query&lt;br /&gt;
--- @param shouldCache bool Whether the query should be cached, default to true&lt;br /&gt;
--- @return table&lt;br /&gt;
function cargo.getQueryResults( tables, fields, args, shouldCache )&lt;br /&gt;
	-- args are optional&lt;br /&gt;
	args = args or {}&lt;br /&gt;
&lt;br /&gt;
	if shouldCache ~= false then shouldCache = true end&lt;br /&gt;
&lt;br /&gt;
	checkType( &amp;#039;Module:Cargo/cargo.getQueryResults&amp;#039;, 1, tables, &amp;#039;string&amp;#039; )&lt;br /&gt;
	checkType( &amp;#039;Module:Cargo/cargo.getQueryResults&amp;#039;, 2, fields, &amp;#039;string&amp;#039; )&lt;br /&gt;
	checkType( &amp;#039;Module:Cargo/cargo.getQueryResults&amp;#039;, 3, args, &amp;#039;table&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
	local argsString = flattenTableToString( args )&lt;br /&gt;
&lt;br /&gt;
	if shouldCache and cache[ tables ] and cache[ tables ][ fields ] and cache[ tables ][ fields ][ argsString ] then&lt;br /&gt;
		return cache[ tables ][ fields ][ argsString ]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local success, results = pcall( extCargo.query, tables, fields, args )&lt;br /&gt;
	-- mw.logObject( { [ &amp;#039;tables&amp;#039; ] = tables, [ &amp;#039;fields&amp;#039; ] =  fields, [ &amp;#039;args&amp;#039; ] =  args }, &amp;#039;[Cargo] Run Cargo query with the following params&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
	if not success then&lt;br /&gt;
		error( &amp;#039;Failed to query Cargo table&amp;#039; )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- mw.logObject( results, &amp;#039;[Cargo] Found Cargo query result&amp;#039; )&lt;br /&gt;
	if shouldCache then&lt;br /&gt;
		cacheQueryResults( results, tables, fields, argsString )&lt;br /&gt;
	end&lt;br /&gt;
	return results&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Implement {{Cargo query}} template&lt;br /&gt;
--- TODO: Implement formats&lt;br /&gt;
---&lt;br /&gt;
--- @return string&lt;br /&gt;
function cargo.getQueryResultsFromWikitext( frame )&lt;br /&gt;
	mArguments = require( &amp;#039;Module:Arguments&amp;#039; )&lt;br /&gt;
	local templateArgs = mArguments.getArgs( frame )&lt;br /&gt;
&lt;br /&gt;
	local tables = templateArgs[ &amp;#039;tables&amp;#039; ]&lt;br /&gt;
	local fields = templateArgs[ &amp;#039;fields&amp;#039; ]&lt;br /&gt;
&lt;br /&gt;
	if not tables or not fields then&lt;br /&gt;
		error( &amp;#039;Missing tables or fields parameter&amp;#039; )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local args = {&lt;br /&gt;
		[ &amp;#039;where&amp;#039; ] = templateArgs[ &amp;#039;where&amp;#039; ],&lt;br /&gt;
		[ &amp;#039;join&amp;#039; ]  = templateArgs[ &amp;#039;join on&amp;#039; ],&lt;br /&gt;
		[ &amp;#039;groupBy&amp;#039; ]  = templateArgs[ &amp;#039;group by&amp;#039; ],&lt;br /&gt;
		[ &amp;#039;having&amp;#039; ] = templateArgs[ &amp;#039;having&amp;#039; ],&lt;br /&gt;
		[ &amp;#039;orderBy&amp;#039; ] = templateArgs[ &amp;#039;order by&amp;#039; ],&lt;br /&gt;
		[ &amp;#039;limit&amp;#039; ] = templateArgs[ &amp;#039;limit&amp;#039; ],&lt;br /&gt;
		[ &amp;#039;offset&amp;#039; ] = templateArgs[ &amp;#039;offset&amp;#039; ]&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	-- Get query results&lt;br /&gt;
	local results = cargo.getQueryResults( tables, fields, args )&lt;br /&gt;
&lt;br /&gt;
	local format = templateArgs[ &amp;#039;format&amp;#039; ]&lt;br /&gt;
	return formatQueryResultsToWikitext( results, format )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Debug function&lt;br /&gt;
function cargo.test( chara )&lt;br /&gt;
	chara = chara or &amp;#039;Venom&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	local tables = &amp;#039;MoveData_GGACR&amp;#039;&lt;br /&gt;
    local fields = &amp;#039;chara,name,input,damage,guard,startup,active,recovery,onBlock,onHit,level,images,hitboxes,notes,caption,hitboxCaption,type,gbp,gbm,tension,prorate,invuln,cancel,blockstun,groundHit,airHit,hitstop,gatlings,frcWindow&amp;#039;&lt;br /&gt;
    local args = {&lt;br /&gt;
        where   = &amp;#039;MoveData_GGACR.chara=&amp;quot;&amp;#039; .. chara .. &amp;#039;&amp;quot;&amp;#039;,&lt;br /&gt;
        orderBy = &amp;#039;MoveData_GGACR._rowID&amp;#039;,&lt;br /&gt;
    }&lt;br /&gt;
	local results = cargo.getQueryResults( tables, fields, args )&lt;br /&gt;
	mw.logObject( results, &amp;#039;[Cargo] Test function output&amp;#039; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return cargo&lt;/div&gt;</summary>
		<author><name>圈圈菌Q</name></author>
	</entry>
</feed>