Skip to content

Commit a3dad8d

Browse files
committed
db-tabulator: merge in params from wikitext along with ones from lua
!restart
1 parent c3e8166 commit a3dad8d

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

db-tabulator/app.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,23 @@ export class Query extends EventEmitter {
249249
return;
250250
}
251251
this.template = templates[0];
252+
253+
// Merge in configs provided in wikitext
254+
let templateOverrides = [];
255+
for (let origParam of this.originalTemplate.parameters) {
256+
if (origParam.value && !origParam.name.toString().startsWith('lua_')) {
257+
const param = this.template.parameters.find(p => p.name === origParam.name)
258+
if (param) {
259+
param.value = origParam.value;
260+
} else {
261+
this.template.parameters.push(origParam);
262+
}
263+
templateOverrides.push(origParam.name);
264+
}
265+
}
266+
if (templateOverrides.length > 0) {
267+
this.emit('lua-wikitext-overrides', templateOverrides.join(', '));
268+
}
252269
}
253270

254271
this.config.interval = parseInt(this.getTemplateValue('interval'));

db-tabulator/database-report.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
'lua-executing': data => `Executing ${link('Module:' + data.args[0])}, function <code>${data.args[1]}</code> ${data.args[2] ? 'with params ' + data.args[2] : 'without any params.'}`,
5454
'lua-executed': data => `Lua module output: <pre>${data.args[0]}</pre>`,
5555
'lua-no-template': _ => 'No <code>{' + '{database report}}</code> template found in Lua module output',
56+
'lua-wikitext-overrides': data => `Parameters overridden or defined via template: ${data.args[0]}`,
5657
'no-sql': _ => 'No <code>|sql=</code> parameter found in {' + '{database report}}',
5758
'query-executing': data => `Query (<code>${shorten(data.args[0], 80)}</code>) submitted to database.`,
5859
'query-executed': data => `Query finished running in ${data.args[0]} seconds.`,

0 commit comments

Comments
 (0)