Module:Liste1 : Différence entre versions
Ligne 30 : | Ligne 30 : | ||
for _, row in ipairs(result) do | for _, row in ipairs(result) do | ||
− | if row['dateDebut'] then | + | if row['dateDebut'] and row['dateDebut'] ~= '' then |
if row['dateFin'] then | if row['dateFin'] then | ||
local a = tonumber(string.sub(row['dateDebut'],1,4)) + tonumber(string.sub(row['dateFin'],1,4)) | local a = tonumber(string.sub(row['dateDebut'],1,4)) + tonumber(string.sub(row['dateFin'],1,4)) |
Version du 10 décembre 2018 à 10:10
La documentation pour ce module peut être créée à Module:Liste1/doc
local p = {} function p.main(frame) if frame == mw.getCurrentFrame() then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame() end local query = {} for k, v in pairs(args) do if string.sub(k, 0, 2) == 'q?' then query[string.sub(k, 3)] = v end end supports={} local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = 'idSupport',limit='3000'}) for d, row in ipairs(result) do supports[row['idSupport']] = row['video'] end result = mw.ext.cargo.query(query.tables, query.fields, query) local resulta = mw.ext.cargo.query('Sequences','apercu,_pageName,titre,realisateurs,fonds,dateDebut,dateFin,resumefr,resumeen,resumede,idSupport,timecode,duree,video,thematique',{groupBy = '_pageName',limit='3000'}) if not next(result) then return frame:preprocess(args.default or '') end local tbl = {} for _, row in ipairs(result) do if row['dateDebut'] and row['dateDebut'] ~= '' then if row['dateFin'] then local a = tonumber(string.sub(row['dateDebut'],1,4)) + tonumber(string.sub(row['dateFin'],1,4)) row['annee'] = (a-a%2)/2 else row['annee'] = string.sub(row['dateDebut'],1,4) end elseif row['dateFin'] then row['annee'] = string.sub(row['dateFin'],1,4) else row['annee'] = '?' end if row['video'] == '' then if supports[row['idSupport']] then row['video']=supports[row['idSupport']] end end tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row } end local intro = frame:preprocess(args.intro or '') local outro = frame:preprocess(args.outro or '') return #resulta .. intro .. table.concat(tbl,args.delimiter or '') .. outro end return p