Module:Sandbox/Habst/Athletics PBs

p = {}

local P_PERSONALBEST = 'P2415' local P_POINTINTIME = 'P585' local P_SPORTSDISCIPLINE = 'P2416' local P_LOCATION = 'P276' local P_NUMBEROFPOINTS = 'P1351'

p.pbs = function(frame) local qid = frame.args[1] local ent = mw.wikibase.getEntity(qid) local pbClaims = ent['claims'][P_PERSONALBEST] local out = '' output = output .. '{| class="wikitable mw-collapsible mw-collapsed" border="1" style="border-collapse:collapse; width:100%; margin:0;"\n' output = output .. '!colspan=11|PBs\n' for i, pc in ipairs(pbClaims) do		mw.logObject(mw.wikibase.renderSnak(pc['mainsnak'])) if pc['qualifiers'] then local fulldate = pc['qualifiers'][P_POINTINTIME][1]['datavalue']['value']['time'] local year = fulldate:sub(2, 5) local mark = mw.wikibase.renderSnak(pc['mainsnak']['datavalue']['value']['amount']):match('([^±]*)') --local meetname = mw.wikibase.renderSnak(pc['mainsnak']) output = output .. '|-\n' output = output .. '|style="width:5%;"|' .. fulldate:sub(7, 11) local location = mw.wikibase.renderSnak(pc['qualifiers'][P_LOCATION][1]) output = output .. '||style="width:10%;"|' .. location local discipline = mw.wikibase.renderSnak(pc['qualifiers'][P_SPORTSDISCIPLINE][1]) output = output .. '||style="width:10%;"|' .. discipline local ranking = 'NR' if pc['qualifiers'][P_NUMBEROFPOINTS] then ranking = pc['qualifiers'][P_NUMBEROFPOINTS][1]['datavalue']['value']['amount']:sub(2) end output = output .. '||style="width:5%;"|' .. ranking output = output .. '||style="width:5%;"|' .. mark output = output .. '\n' end end return output end return p