<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FNettrom%2FSuggestBot</id>
	<title>Module:Sandbox/Nettrom/SuggestBot - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FNettrom%2FSuggestBot"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Nettrom/SuggestBot&amp;action=history"/>
	<updated>2026-07-28T13:36:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Nettrom/SuggestBot&amp;diff=145909&amp;oldid=prev</id>
		<title>imported&gt;Nettrom: neat, there&#039;s also a 0-star image</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Nettrom/SuggestBot&amp;diff=145909&amp;oldid=prev"/>
		<updated>2015-08-13T17:08:29Z</updated>

		<summary type="html">&lt;p&gt;neat, there&amp;#039;s also a 0-star image&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- List of all columns and their respective header titles&lt;br /&gt;
local table_columns = {&amp;#039;Views/Day&amp;#039;, &amp;#039;Quality&amp;#039;, &amp;#039;Title&amp;#039;, &amp;#039;Content&amp;#039;, &amp;#039;Headings&amp;#039;,&lt;br /&gt;
	&amp;#039;Images&amp;#039;, &amp;#039;Links&amp;#039;, &amp;#039;Sources&amp;#039;, &amp;#039;Tagged with…&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
-- Mapping of shortnames for task categories and their respective text&lt;br /&gt;
-- For more information, see User:SuggestBot/Documentation/Task categories&lt;br /&gt;
local task_map = {source=&amp;#039;Add sources&amp;#039;, cleanup=&amp;#039;Cleanup&amp;#039;, expand=&amp;#039;Expand&amp;#039;,&lt;br /&gt;
	unenc=&amp;#039;Unencyclopaedic&amp;#039;, merge=&amp;#039;Merge&amp;#039;, wikify=&amp;#039;Wikify&amp;#039;, orphan=&amp;#039;Orphan&amp;#039;,&lt;br /&gt;
	stub=&amp;#039;Stub&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
-- Mapping of assessment class names to indexes for sorting&lt;br /&gt;
local rating_sort = {FA=7, A=6, GA=5, B=4, C=3, Start=2, Stub=1, NA=0}&lt;br /&gt;
&lt;br /&gt;
-- Mapping of quality levels into images&lt;br /&gt;
local rating_level = {FA=&amp;#039;High&amp;#039;, A=&amp;#039;High&amp;#039;, GA=&amp;#039;High&amp;#039;, B=&amp;#039;Medium&amp;#039;, C=&amp;#039;Medium&amp;#039;,&lt;br /&gt;
	Start=&amp;#039;Low&amp;#039;, Stub=&amp;#039;Low&amp;#039;, NA=&amp;#039;Unassessed&amp;#039;}&lt;br /&gt;
local rating_images = {High=&amp;#039;File:Stars330.svg&amp;#039;, Medium=&amp;#039;File:Stars320.svg&amp;#039;,&lt;br /&gt;
	Low=&amp;#039;File:Stars310.svg&amp;#039;, Unassessed=&amp;#039;File:Stars300.svg&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
-- List of task columns in order so we can flag if in need of improvement&lt;br /&gt;
local task_list = {&amp;#039;content&amp;#039;, &amp;#039;headings&amp;#039;, &amp;#039;images&amp;#039;, &amp;#039;links&amp;#039;, &amp;#039;sources&amp;#039;}&lt;br /&gt;
-- Mapping of tasks to explanations (used in the image alt-text)&lt;br /&gt;
local task_explanations = {content=&amp;#039;Please add more content&amp;#039;,&lt;br /&gt;
	headings=&amp;#039;Please create proper section headings&amp;#039;,&lt;br /&gt;
	images=&amp;#039;Please add more images&amp;#039;, links=&amp;#039;Please add more wikilinks&amp;#039;,&lt;br /&gt;
	sources=&amp;#039;Please add more sources&amp;#039;}&lt;br /&gt;
-- Title of the image file we use to flag tasks&lt;br /&gt;
local task_image = &amp;#039;Flag icon red 3.svg&amp;#039;&lt;br /&gt;
-- [[File:Flag icon red 3.svg|18px|alt=Please add more content|link=Yamaha electric guitar models|Please add more content]]&lt;br /&gt;
&lt;br /&gt;
-- Hello world to test that the module works...&lt;br /&gt;
function p.hello_world()&lt;br /&gt;
	return &amp;quot;Hello, world!&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function translate_quality(tbl_row, title, rating, prediction)&lt;br /&gt;
	-- Add a table cell with quality information&lt;br /&gt;
	local qual_lvl = rating_level[prediction]&lt;br /&gt;
	local qual_text = &amp;#039;[[&amp;#039; .. rating_images[qual_lvl] ..&lt;br /&gt;
		&amp;#039;|60px|alt=Quality: &amp;#039; .. qual_lvl .. &amp;#039;, Assessed class: &amp;#039; ..&lt;br /&gt;
		rating .. &amp;#039;, Predicted class: &amp;#039; .. prediction .. &amp;#039;|link=&amp;#039; ..&lt;br /&gt;
		title .. &amp;#039;|Quality: &amp;#039; .. qual_lvl .. &amp;#039;, Assessed class: &amp;#039; ..&lt;br /&gt;
		rating .. &amp;#039;, Predicted class: &amp;#039; .. prediction .. &amp;#039;]]&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	-- Create a table cell with information about article quality&lt;br /&gt;
	local qualcell = tbl_row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
	-- Add the sortkey from mapping predicted class to a number&lt;br /&gt;
	add_sortkey(qualcell, rating_sort[prediction])&lt;br /&gt;
	qualcell:wikitext(qual_text)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function add_sortkey(tblcell, value)&lt;br /&gt;
	return tblcell:tag(&amp;#039;span&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;sortkey&amp;#039;)&lt;br /&gt;
		:wikitext(value)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function add_tasks(tbl_row, tasks, title)&lt;br /&gt;
	-- For each task we now about, see if it&amp;#039;s in task and act accordingly&lt;br /&gt;
	for i, task in ipairs(task_list) do&lt;br /&gt;
		local taskcell = tbl_row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		if string.find(tasks, task) then&lt;br /&gt;
			add_sortkey(taskcell, &amp;#039;0&amp;#039;)&lt;br /&gt;
			taskcell:wikitext(&amp;#039;[[File:&amp;#039; .. task_image .. &amp;#039;|18px|alt=&amp;#039; ..&lt;br /&gt;
				task_explanations[task] .. &amp;#039;|link=&amp;#039; .. title .. &amp;#039;|&amp;#039; .. &lt;br /&gt;
				task_explanations[task] .. &amp;#039;]]&amp;#039;)&lt;br /&gt;
		else&lt;br /&gt;
			add_sortkey(taskcell, &amp;#039;2&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function build_header(tbl)&lt;br /&gt;
	local t_row = tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	for i, title in ipairs(table_columns) do&lt;br /&gt;
		t_row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;scope&amp;#039;, &amp;#039;col&amp;#039;)&lt;br /&gt;
			:wikitext(title)&lt;br /&gt;
			:newline()&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function add_row(tbl)&lt;br /&gt;
	-- Adds a suggestion row to the table&lt;br /&gt;
	return tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;height&amp;#039;, &amp;#039;30px&amp;#039;)&lt;br /&gt;
		:newline()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function add_cells(tbl_row, tag, title, views, rating, prediction, tasks)&lt;br /&gt;
	-- 	Add the table cells for the suggestion based on the given parameters&lt;br /&gt;
	local tag_text = task_map[tag]&lt;br /&gt;
	&lt;br /&gt;
	-- First column is number of views&lt;br /&gt;
	tbl_row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;text-align&amp;#039;, &amp;#039;right&amp;#039;)&lt;br /&gt;
		:wikitext(views)&lt;br /&gt;
		&lt;br /&gt;
	-- Second column is article quality&lt;br /&gt;
	translate_quality(tbl_row, title, rating, prediction)&lt;br /&gt;
	&lt;br /&gt;
	-- Third column is a link to the article and its talk page&lt;br /&gt;
	tbl_row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;text-align&amp;#039;, &amp;#039;left&amp;#039;)&lt;br /&gt;
		:wikitext(&amp;#039;[[&amp;#039; .. title .. &amp;#039;]] &amp;lt;small&amp;gt;([[Talk:&amp;#039; .. title .. &amp;#039;|talk]])&amp;lt;/small&amp;gt;&amp;#039;)&lt;br /&gt;
		&lt;br /&gt;
	-- Fourth through eighth columns are the tasks&lt;br /&gt;
	add_tasks(tbl_row, tasks, title)&lt;br /&gt;
	&lt;br /&gt;
	-- Last column is the article&amp;#039;s task category&lt;br /&gt;
	tbl_row:tag(&amp;#039;td&amp;#039;):wikitext(task_map[tag])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.build_table(frame)&lt;br /&gt;
	-- Build the entire suggestion table.&lt;br /&gt;
	-- Expects a set of &amp;#039;n&amp;#039; suggestions, where each suggestion has&lt;br /&gt;
	-- a total of six parameters, in order as follows:&lt;br /&gt;
	-- 1: Task category&lt;br /&gt;
	-- 2: Article title&lt;br /&gt;
	-- 3: Avg. no. of article views/day for past 14 days&lt;br /&gt;
	-- 4: Assessed quality class&lt;br /&gt;
	-- 5: Predicted quality class&lt;br /&gt;
	-- 6: Comma-separated list of tasks to flag&lt;br /&gt;
	&lt;br /&gt;
	-- What language are we talking?&lt;br /&gt;
	local lang = mw.language.getContentLanguage()&lt;br /&gt;
	&lt;br /&gt;
	local table = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;wikitable&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;sortable&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;border&amp;#039;, &amp;#039;1&amp;#039;)&lt;br /&gt;
	build_header(table)&lt;br /&gt;
&lt;br /&gt;
	-- 0-based index of the current article being processed	&lt;br /&gt;
	local cur_art = 0&lt;br /&gt;
&lt;br /&gt;
	while frame.args[(cur_art * 6) + 1] do&lt;br /&gt;
		local cur_idx = cur_art * 6&lt;br /&gt;
		local newrow = add_row(table)&lt;br /&gt;
		-- Use the formatnum parser function to format number of views&lt;br /&gt;
		local n_views = lang:formatNum(tonumber(frame.args[cur_idx + 3]))&lt;br /&gt;
		add_cells(newrow, frame.args[cur_idx + 1], frame.args[cur_idx + 2],&lt;br /&gt;
			n_views, frame.args[cur_idx + 4],&lt;br /&gt;
			frame.args[cur_idx + 5], frame.args[cur_idx + 6])&lt;br /&gt;
		cur_art = cur_art + 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(table)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.nargs(frame)&lt;br /&gt;
	local i = 0&lt;br /&gt;
	local output = &amp;#039;&amp;#039;&lt;br /&gt;
	while frame.args[(i * 6) + 1] do&lt;br /&gt;
		output = output .. &amp;#039;Processing article &amp;#039; .. i .. &amp;#039;... &amp;#039;&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Nettrom</name></author>
	</entry>
</feed>