Skip to content

Commit

Permalink
db-tabulator: allow putting sql in nowiki tags
Browse files Browse the repository at this point in the history
!web-restart
  • Loading branch information
siddharthvp committed Mar 9, 2024
1 parent 2ac8eda commit 688975f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/toolforge-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
exit 1;
fi;
npm restart;
elif [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "web-endpoint")" -gt 0 || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!restart"* ]]; then
elif [[ "$(git diff --name-only HEAD HEAD@{1} | grep -c "web-endpoint")" -gt 0 || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!restart"* || "$(git rev-list --format=%B --max-count=1 HEAD)" == *"!web-restart"* ]]; then
echo "Restarting SDZeroBot webservice ...";
cd /data/project/sdzerobot/www/js && npm restart;
fi;
Expand Down
17 changes: 14 additions & 3 deletions db-tabulator/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,25 @@ export class Query {
return this.template.getValue(param)?.replace(/<!--.*?-->/g, '').trim();
}

getSql() {
let sql = this.getTemplateValue('sql');
if (/^\s*<nowiki ?>/.test(sql)) {
return sql.replace(/^\s*<nowiki ?>/, '')
.replace(/<\/nowiki ?>\s*$/, '');
} else {
// @deprecated
return sql
// Allow pipes to be written as {{!}}
?.replace(/\{\{!\}\}/g, '|');
}
}

// Errors in configs are reported to user through [[Module:Database report]] in Lua
parseQuery() {
this.config.interval = parseInt(this.getTemplateValue('interval'));

// Use of semicolons for multiple statements will be flagged as error at query runtime
this.config.sql = this.getTemplateValue('sql')
// Allow pipes to be written as {{!}}
?.replace(/\{\{!\}\}/g, '|');
this.config.sql = this.getSql();

if (!this.config.sql) {
this.isValid = false;
Expand Down

0 comments on commit 688975f

Please sign in to comment.