Module:Database reports/Hot articles
Appearance
This module triggers generation of a list of "hot" (most edited) articles from a WikiProject. This supersedes lists created by User:HotArticlesBot.
Usage
[edit]{{Database report
| lua_source = Module:Database reports/Hot articles
| lua_arg_project = <!-- Name of the WikiProject or task force, see https://en.wikipedia.org/w/api.php?action=query&utf8=1&list=projects&pjsubprojects=1 for the list of valid names -->
| lua_arg_articles = 10 <!-- Number of hot articles to list -->
| lua_arg_days = 7 <!-- Number of days to count edits from (1–30) -->
| lua_arg_orange = 15 <!-- Number of edits required to hit the orange threshold -->
| lua_arg_red = 30 <!-- Number of edits required to hit the red threshold -->
| silent = <!-- Set to yes (or any value) to suppress the boilerplate text. Note this also suppresses the update link. -->
}}
{{Database report end}}
See also
[edit]- Module:Database reports/Hot articles by category – by talk page category instead of WikiProject
local Report = require('Module:Database report')
local Arguments = require('Module:Arguments')
local p = {}
p.main = function(frame)
local args = Arguments.getArgs(frame)
local report = Report:new()
local project = args.project
local articles = args.articles or '10'
local days = args.days or '7'
local red = args.red or '30'
local orange = args.orange or '15'
if project == nil then
return invalid('|project= parameter is unspecified')
end
if tonumber(articles) == nil or tonumber(articles) < 1 then
return invalid('articles must be a number >= 1')
end
if tonumber(days) == nil or tonumber(days) < 1 or tonumber(days) > 30 then
return invalid('days must be between 1 and 30')
end
if tonumber(red) == nil or tonumber(red) < 1 then
return invalid('red: threshold must be a number >= 1')
end
if tonumber(orange) == nil or tonumber(orange) < 1 then
return invalid('orange: threshold must be a number >= 1')
end
report:setSQL([[
WITH hotarticles_presort AS (
WITH inprojectarticleedits AS (
SELECT *
FROM page_assessments_projects
JOIN page_assessments ON pa_project_id = pap_project_id AND pa_class NOT IN ('Disambig', 'Redirect')
JOIN revision ON rev_page = pa_page_id AND rev_timestamp > (NOW() - INTERVAL ]]..days..[[ DAY)
JOIN page ON page_id = rev_page AND page_namespace = 0
WHERE pap_project_title = ']]..project..[['
)
SELECT COUNT(*) AS Edits, page_title AS Article, pa_class AS Rating
FROM inprojectarticleedits
GROUP BY page_title
ORDER BY Edits DESC
FETCH FIRST ]]..articles ..[[ ROWS WITH TIES
)
SELECT *,
ROW_NUMBER() OVER(ORDER BY Edits DESC, Article ASC) AS RowNum,
IF(EDITS > ]]..red..[[, 'c60d27', IF(EDITS > ]]..orange..[[, 'f75a0d', 'ff9900')) AS Color
FROM hotarticles_presort
ORDER BY Edits DESC, Article ASC
]])
report:useWikilinks(2)
report:setWidth(1, '3em')
report:setWidth(3, '4em')
report:setTableStyle('overflow-wrap: anywhere; border-width: 0; border-collapse: separate; border-spacing: 0 1px')
report:setTableClass('wikitable')
report:setInterval(1)
report:setRowTemplate('Hot articles report row')
report:setHeaderTemplate('Hot articles report header')
return report:generate()
end
function invalid(text)
return require('Module:Error').error{ 'Invalid configuration: '.. text, tag = 'p' }
end
return p