Module:PlayerObbiesList
From Obby Wiki
More actions
Documentation for this module may be created at Module:PlayerObbiesList/doc
--[=[
DO NOT EDIT THIS FILE MANUALLY.
This file was automatically minified and transpiled from Luau by DarkLua.
The original source code was written in Luau, the below code is transpiled and compatible with Lua 5.1.5 and contains the necessary polyfills.
Uploaded automatically via WikiWire. View the original source at our central code repository: https://github.com/obbywiki/modules
ANY EDITS WILL LIKELY BE OVERWRITTEN. A copyright notice should be supplied at the bottom of this page.
]=]--
local PlayerObbiesList={}local months_full={'January','February','March','April','May','June','July','August','September','October','November','December'}local function month_by_index(month)return months_full[month]or'N/A'end local function get_comma_val(num)local formatted=num while true do local k formatted,k=string.gsub(formatted,'^(-?%d+)(%d%d%d)','%1,%2')if(k==0)then break end end return formatted end function PlayerObbiesList.main(frame)if not mw.ext.cargo or not mw.ext.cargo.query then return[[An unexpected error occurred and this user's obbies and contributions could not be loaded at this time. Please check back later.]]end local args=require('Module:Arguments').getArgs(frame)local username=args.username if not username then return'No username provided'end if string.sub(username,1,1)=='@'then username=string.sub(username,2)end local developers_held_data=mw.ext.cargo.query('Obbies',[[_pageName=name, visits, month, year, thumbnail, likes, dislikes]],{where="developers HOLDS '@"..username.."'",orderBy='visits DESC',limit=30})local contributors_held_data=mw.ext.cargo.query('Obbies',[[_pageName=name, visits, month, year, thumbnail, likes, dislikes]],{where="contributors HOLDS '@"..username.."'",orderBy='visits DESC',limit=30})local creator_is_data=mw.ext.cargo.query('Obbies',[[_pageName=name, visits, month, year, thumbnail, likes, dislikes]],{where="creator = '@"..username.."' AND NOT (developers HOLDS '@"..username.."')",orderBy='visits DESC',limit=30})local developed_data={}for _,v in ipairs(developers_held_data)do table.insert(developed_data,v)end for _,v in ipairs(creator_is_data)do table.insert(developed_data,v)end table.sort(developed_data,function(a,b)return tonumber(a.visits)>tonumber(b.visits)end)local rendered=string.format([[@%s has '''%s+''' obbies they have developed themselves or have been on or currently is on the development team for:]],tostring(username),tostring(#developed_data))local tbl=mw.html.create('table'):addClass('wikitable sortable plainlinks'):addClass('mw-collapsible mw-made-collapsible wikitable--fluid'):css('width','100%')local thead=tbl:tag('tr')thead:tag('th'):wikitext('Thumbnail')thead:tag('th'):wikitext('Name')thead:tag('th'):wikitext('Visits')thead:tag('th'):wikitext('Rating')thead:tag('th'):wikitext('Date')for _,v in ipairs(developed_data)do local row=tbl:tag('tr')local thumb_cell=row:tag('td')thumb_cell:wikitext(string.format('[[File:%s|120px|alt=%s|link=%s]]',tostring(v.thumbnail),tostring(v.name),tostring(v.name)))local total_likes=tonumber(v.likes)or 0 local total_dislikes=tonumber(v.dislikes)or 0 row:tag('td'):wikitext(string.format('[[%s]]',tostring(v.name)))row:tag('td'):wikitext(tostring(get_comma_val(v.visits)))row:tag('td'):wikitext((total_likes+total_dislikes)>0 and(math.floor((total_likes/(total_likes+total_dislikes))*1000)/10)..'% ( [[File:Likes.svg|12px|alt=Likes|link=]] '..get_comma_val(tostring(total_likes))..' [[File:Dislikes.svg|12px|alt=Dislikes|link=]] '..get_comma_val(tostring(total_dislikes))..')'or'N/A')row:tag('td'):wikitext(string.format('%s %s',tostring(month_by_index(tonumber(v.month))),tostring(v.year)))end local cont_tbl if#contributors_held_data>0 then cont_tbl=mw.html.create('table'):addClass('wikitable sortable plainlinks'):addClass('mw-collapsible mw-made-collapsible wikitable--fluid'):css('width','100%')local cthead=cont_tbl:tag('tr')cthead:tag('th'):wikitext('Thumbnail')cthead:tag('th'):wikitext('Name')cthead:tag('th'):wikitext('Visits')cthead:tag('th'):wikitext('Rating')cthead:tag('th'):wikitext('Date')for _,v in ipairs(contributors_held_data)do local row=cont_tbl:tag('tr')local thumb_cell=row:tag('td')thumb_cell:wikitext(string.format('[[File:%s|120px|alt=%s|link=%s]]',tostring(v.thumbnail),tostring(v.name),tostring(v.name)))local total_likes=tonumber(v.likes)or 0 local total_dislikes=tonumber(v.dislikes)or 0 row:tag('td'):wikitext(string.format('[[%s]]',tostring(v.name)))row:tag('td'):wikitext(tostring(get_comma_val(v.visits)))row:tag('td'):wikitext((total_likes+total_dislikes)>0 and(math.floor((total_likes/(total_likes+total_dislikes))*1000)/10)..'% ( [[File:Likes.svg|12px|alt=Likes|link=]] '..get_comma_val(tostring(total_likes))..' [[File:Dislikes.svg|12px|alt=Dislikes|link=]] '..get_comma_val(tostring(total_dislikes))..')'or'N/A')row:tag('td'):wikitext(string.format('%s %s',tostring(month_by_index(tonumber(v.month))),tostring(v.year)))end end rendered=rendered..tostring(tbl)if cont_tbl then rendered=rendered..'\n\n'..tostring(mw.html.create('h2'):wikitext('Contributions'))..string.format([[Below are all of @%s's contributed obbies. Contributions are typically considered to be one-off contract work for games they are not core developers of. Work varies by developer and game, but typically contributors are one-time level designers, map creators, or other short-term work. @%s has contributed to '''%s+''' obbies that are documented on the Obby Wiki.]],tostring(username),tostring(username),tostring(#contributors_held_data))..tostring(cont_tbl)end return rendered..'\n\n'end return PlayerObbiesList