Content added Content deleted
mNo edit summary |
(added visibility arguments) |
||
Line 17: | Line 17: | ||
end |
end |
||
local function formatDuration( |
local function formatDuration(startDt, endDt) |
||
if |
if startDt and endDt then |
||
return string.format( |
return string.format( |
||
'Start: %s <br> End: %s', |
'Start: %s <br> End: %s', |
||
startDt, |
|||
endDt |
|||
) |
) |
||
end |
end |
||
Line 54: | Line 54: | ||
datatable |
datatable |
||
:setColumns{ |
:setColumns{ |
||
{ |
|||
{ name = 'logo', header = 'Logo', data_fields = { 'logo' }, func = formatLogo, css = { ['width'] = '192px' }, sortable = false }, |
|||
⚫ | |||
{ name = 'name', header = 'Gacha', data_fields = { '_pageName', 'gacha_name' }, func = formatName }, |
|||
header = 'Logo', |
|||
{ name = 'duration', header = 'Gacha period', data_fields = { 'start', 'end' }, func = formatDuration, css = { ['white-space'] = 'nowrap' }, css = { ['width'] = '200px' } }, |
|||
dataFields = { 'logo' }, |
|||
⚫ | |||
func = formatLogo, |
|||
:setHeaders{ |
|||
css = { ['width'] = '192px' }, |
|||
⚫ | |||
sortable = false |
|||
⚫ | |||
}, |
|||
{ |
|||
⚫ | |||
header = 'Gacha', |
|||
dataFields = { '_pageName', 'gacha_name' }, |
|||
func = formatName |
|||
⚫ | |||
{ |
|||
name = 'duration', |
|||
header = 'Gacha period', |
|||
dataFields = { 'start', 'end' }, |
|||
func = formatDuration, |
|||
css = { ['white-space'] = 'nowrap', ['width'] = '200px' }, |
|||
visible = false |
|||
}, |
|||
} |
} |
||
:setData(qb:query()) |
:setData(qb:query()) |
Revision as of 19:31, 3 February 2022
This module depends on the following other modules: |
To generate {{Gacha datatable}}, invoke using the main function.
local getArgs = require('Module:Arguments').getArgs
local DatatableBuilder = require('Module:DatatableBuilder')
local QueryBuilder = require('Module:QueryBuilder')
local p = {}
local function formatLogo(logo)
if logo then
return string.format('[[File:%s|192px]]', logo)
end
return nil
end
local function formatName(pageName, gachaName)
return string.format('[[%s|%s]]', pageName, gachaName)
end
local function formatDuration(startDt, endDt)
if startDt and endDt then
return string.format(
'Start: %s <br> End: %s',
startDt,
endDt
)
end
end
function p.main(frame)
local args = getArgs(frame)
local qb = QueryBuilder.new()
qb
:setTables('Gachas')
:setFields([[
_pageName,
gacha_name,
logo,
DATE_FORMAT(DATE_ADD(start, INTERVAL 9 HOUR), "%Y/%m/%d, %H:%i JST") = start,
DATE_FORMAT(DATE_ADD(end, INTERVAL 9 HOUR), "%Y/%m/%d, %H:%i JST") = end,
]])
:addWhere('gacha_id', '>', 0)
:setOrderBy('Gachas.start ASC')
:setGroupBy('_pageName')
:setLimit(200)
qb
:addWhere('start', '<', args['start before'])
:addWhere('start', '>', args['start after'])
:addWhere('end', '<', args['end before'])
:addWhere('end', '>', args['end after'])
local datatable = DatatableBuilder.new()
datatable
:setColumns{
{
name = 'logo',
header = 'Logo',
dataFields = { 'logo' },
func = formatLogo,
css = { ['width'] = '192px' },
sortable = false
},
{
name = 'name',
header = 'Gacha',
dataFields = { '_pageName', 'gacha_name' },
func = formatName
},
{
name = 'duration',
header = 'Gacha period',
dataFields = { 'start', 'end' },
func = formatDuration,
css = { ['white-space'] = 'nowrap', ['width'] = '200px' },
visible = false
},
}
:setData(qb:query())
return datatable:tostring()
end
return p