Module

Leaderboard: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
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 PropList = ""
Line 19: Line 26:
local debugtext = ""
local debugtext = ""
local count = tonumber(frame:callParserFunction('#ask',{'[[Category:'..mainCat..']][[Taxonomy::'..taxon..']][[Week::'..week..']][[Generation::'..gen..']]'..whateverProperty,format="count"}))
local count = tonumber(frame:callParserFunction('#ask',{'[[Category:'..mainCat..']][[Biota type::'..biotatype..']][[Taxonomy::'..taxon..']][[Week::'..week..']][[Generation::'..gen..']][[Status::'..exstatus..']]'..whateverProperty..exgen,format="count"}))
local smwlimit = 500
local smwlimit = 500
Line 29: Line 36:
debugtext = debugtext..", and yet we see the offset at "..currentOffset
debugtext = debugtext..", and yet we see the offset at "..currentOffset
end
end
local smwResult = frame:callParserFunction('#ask',{'[[Category:'..mainCat..']][[Taxonomy::'..taxon..']][[Week::'..week..']][[Generation::'..gen..']]'..whateverProperty,"?"..leaderType,limit=tostring(smwlimit),searchlabel="",offset=tostring(currentOffset),format="plainlist",headers="hide",mainlabel="-"})
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
if smwResult == "" then break end
PropList = PropList..", "..smwResult
PropList = PropList..", "..smwResult
Line 54: 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=propval,total=count})
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
table.insert(proxyTable,{property=propval,total=count})
end
end
end
Line 62: 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 75: Line 91:
end
end
return leaderboardTable--.."\n"..debugtext--..PropList
return frame:preprocess(leaderboardTable)--.."\n"..debugtext--..PropList
end
end


Cookies help us deliver our services. By using our services, you agree to our use of cookies.