Module

Leaderboard: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(18 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 "Eukaryota" --Ever wanted to know who made the most saucebacks? Was it Ovi? Was it Hydro? Was it me? Who knows!
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 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
while not endNextLoop do
while not endNextLoop do
if currentOffset > count then
if smwlimit ~= 500 then
smwlimit = currentOffset - count
debugtext = currentOffset..", "..count..", "..smwlimit
endNextLoop = true
endNextLoop = true
end
end
if currentOffset > count then
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="-"})
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
if smwResult == "" then break end
PropList = PropList..", "..smwResult
PropList = PropList..", "..smwResult
if currentOffset + 500 > count then
currentOffset = currentOffset + 500
currentOffset = currentOffset + (currentOffset + 500 - count)
else
currentOffset = currentOffset + 500
end
--debugtext = debugtext.."\n\n"..tostring(currentOffset)
--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
end
Line 52: 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 60: 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 73: 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.