Module:Signature review
From BugSigDB
Documentation for this module may be created at Module:Signature review/doc
local p = {}
local reviewCache = {}
local function getReviewScore( frame, target )
if reviewCache[target] == nil then
reviewCache[target] = frame:callParserFunction(
'#show',
target,
'?Review score'
)
end
return reviewCache[target]
end
function p.calcScore( frame, studyId, sigId )
local show = getReviewScore( frame, 'Review:' .. studyId .. '/' .. sigId )
if show == '' then
if string.match( sigId, "%D") then
show = "Review needed"
else
show = "No known issues"
end
end
frame:callParserFunction(
'#subobject',
'Review subject=' .. sigId,
'Review score=' .. show
)
return show
end
local function scoreToClass(score)
if score == 'Follow-up needed' then
return 'warning'
end
if score == 'Review needed' then
return 'danger'
end
if score == 'Not fixable' then
return 'muted'
end
if score == 'No known issues' then
return 'success'
end
return ''
end
-- Template entry point
function p.getStatus( frame )
return p.getStatusReal( frame, frame:getParent().args[1], frame:getParent().args[2] )
end
function p.getStatusReal( frame, curpagename, ncbi )
ncbi = mw.text.trim( ncbi )
local score = p.calcScore( frame, curpagename, ncbi )
local target = 'Review:' .. curpagename .. '/' .. ncbi
-- TODO any way we could combine this with the calcScore call?
local hasScore = getReviewScore( frame, target )
local linkText = '<i class="fas text-' .. scoreToClass( score )
if hasScore ~= "" then
linkText = linkText .. ' fa-comment'
else
linkText = linkText .. ' fa-comment-medical'
end
linkText = linkText .. '" title="' .. score .. ' - Review"></i>'
return frame:callParserFunction(
'#formlink',
'form=TSig Review',
'link text=' .. linkText,
'TSig Review[Review score]=Review needed',
'namespace=Review',
'target=' .. target,
'returnto=' .. mw.title.getCurrentTitle().prefixedText
)
end
return p