Leaderboard: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
(36 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
--Generate a leaderboard of sagan 4 submissions under certain parameters |
--Generate a leaderboard of sagan 4 submissions under certain parameters |
||
local mainCat = frame.args[1] or "Species" --the submission type category to be used (leaving it open for landmarks) |
local mainCat = frame.args[1] or "Species" --the submission type category to be used (leaving it open for landmarks) |
||
local taxon = frame.args["taxon"] or " |
local taxon = frame.args["taxon"] or "+" --Ever wanted to know who made the most saucebacks? Was it Ovi? Was it Hydro? Was it me? Who knows! |
||
local week = frame.args["week"] or "+" --so Species Georg can be overtaken short-term |
local week = frame.args["week"] or "+" --so Species Georg can be overtaken short-term |
||
local gen = frame.args["generation"] or frame.args["gen"] or "+" --or even shorter-term ig |
local gen = frame.args["generation"] or frame.args["gen"] or "+" --or even shorter-term ig |
||
Line 13: | Line 13: | ||
local leaderType = frame.args["property"] or "Creator" |
local leaderType = frame.args["property"] or "Creator" |
||
local label = frame.args["label"] or "Leaderboard" |
local label = frame.args["label"] or "Leaderboard" |
||
local exstatus = frame.args["status"] or "+" |
|||
local biotatype = frame.args["biota type"] or "+" |
|||
local exgen = "" |
|||
if frame.args["exgen"] then |
|||
exgen = "[[exgen::"..frame.args["exgen"].."]]" |
|||
end |
|||
local PropList = "" |
|||
local currentOffset = 0 |
|||
local endNextLoop = false |
|||
local debugtext = "" |
|||
⚫ | |||
local smwlimit = 500 |
|||
while not endNextLoop do |
|||
if smwlimit ~= 500 then |
|||
endNextLoop = true |
|||
end |
|||
if currentOffset > count then |
|||
debugtext = debugtext..", and yet we see the offset at "..currentOffset |
|||
end |
|||
local smwResult = frame:callParserFunction('#ask',{'[[Category:'..mainCat..']][[Biota type::'..biotatype..']][[Taxonomy::'..taxon..']][[Week::'..week..']][[Generation::'..gen..']][[Status::'..exstatus..']]'..whateverProperty..exgen,"?"..leaderType,limit=tostring(smwlimit),searchlabel="",offset=tostring(currentOffset),format="plainlist",headers="hide",mainlabel="-"}) |
|||
if smwResult == "" then break end |
|||
PropList = PropList..", "..smwResult |
|||
currentOffset = currentOffset + 500 |
|||
--debugtext = debugtext.."\n\n"..tostring(currentOffset) |
|||
if currentOffset + 500 > count and endNextLoop == false then |
|||
smwlimit = count - currentOffset |
|||
debugtext = count..", "..currentOffset + smwlimit |
|||
--endNextLoop = true |
|||
end |
|||
end |
|||
⚫ | |||
--local PropArray = string.gmatch(PropList, '([^,]+)') |
--local PropArray = string.gmatch(PropList, '([^,]+)') |
||
local PropTable = {} |
local PropTable = {} |
||
Line 28: | Line 61: | ||
local proxyTable = {} |
local proxyTable = {} |
||
for propval, count in pairs(PropTable) do |
for propval, count in pairs(PropTable) do |
||
if leaderType == "Creator" or leaderType == "Artist" then |
|||
⚫ | |||
table.insert(proxyTable,{property='[[User:'..propval..'|'..propval..']]',total=count}) |
|||
elseif leaderType == "Domain" or leaderType == "Kingdom" or leaderType == "Phylum" or leaderType == "Class" or leaderType == "Order" or leaderType == "Family" then |
|||
table.insert(proxyTable,{property="{{#queryformlink:form=ViewTaxon|query string=ViewTaxon[taxon]="..propval.."&_run|link text="..propval.."}}",total=count}) |
|||
elseif leaderType == "Ancestor" then |
|||
table.insert(proxyTable,{property='[['..propval..']]',total=count}) |
|||
else |
|||
⚫ | |||
end |
|||
end |
end |
||
Line 36: | Line 78: | ||
--generate leaderboard table |
--generate leaderboard table |
||
local leaderboardTable = '{| class="wikitable"\n!colspan="3"|'..label..'!!n/entries\n|-' |
local leaderboardTable = '{| class="wikitable" style="width: 250px;"\n!colspan="3"|'..label..'!!n/entries\n|-' |
||
--local currentPlace = 0 |
--local currentPlace = 0 |
||
--local lastValue = 0 |
--local lastValue = 0 |
||
Line 49: | Line 91: | ||
end |
end |
||
return leaderboardTable |
return frame:preprocess(leaderboardTable)--.."\n"..debugtext--..PropList |
||
end |
end |
||