mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 11:49:02 +08:00
feat(board): support natural-week SQL templates and harden prompt
This commit is contained in:
@@ -238,12 +238,21 @@ const resolveSqlTemplate = (sql: string) => {
|
||||
|
||||
const todayStart = new Date(now)
|
||||
todayStart.setHours(0, 0, 0, 0)
|
||||
const mondayOffset = (todayStart.getDay() + 6) % 7
|
||||
const thisWeekStart = at(-mondayOffset)
|
||||
thisWeekStart.setHours(0, 0, 0, 0)
|
||||
const lastWeekStart = at(-mondayOffset - 7)
|
||||
lastWeekStart.setHours(0, 0, 0, 0)
|
||||
|
||||
return sql
|
||||
.split("{{now}}")
|
||||
.join(formatIso(now))
|
||||
.split("{{today_start}}")
|
||||
.join(formatIso(todayStart))
|
||||
.split("{{this_week_start}}")
|
||||
.join(formatIso(thisWeekStart))
|
||||
.split("{{last_week_start}}")
|
||||
.join(formatIso(lastWeekStart))
|
||||
.split("{{since_7d}}")
|
||||
.join(formatIso(at(-7)))
|
||||
.split("{{since_30d}}")
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
"todayAnswered": "Today"
|
||||
},
|
||||
"sqlPlaceholder": "Enter SQL (single SELECT / WITH query only)",
|
||||
"templateHint": "Template variables: {{today_start}}, {{since_7d}}, {{since_30d}}, {{now}}",
|
||||
"templateHint": "Template variables: {{today_start}}, {{this_week_start}}, {{last_week_start}}, {{since_7d}}, {{since_30d}}, {{now}}",
|
||||
"templateDescription": "Use template variables directly in SQL. They will be replaced with ISO timestamps at runtime for both SQLite and PostgreSQL.",
|
||||
"saving": "Saving...",
|
||||
"saveFailed": "Failed to save boards",
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
"todayAnswered": "今日回答"
|
||||
},
|
||||
"sqlPlaceholder": "输入 SQL(仅支持单条 SELECT / WITH 查询)",
|
||||
"templateHint": "支持时间模板变量:{{today_start}}、{{since_7d}}、{{since_30d}}、{{now}}",
|
||||
"templateHint": "支持时间模板变量:{{today_start}}、{{this_week_start}}、{{last_week_start}}、{{since_7d}}、{{since_30d}}、{{now}}",
|
||||
"templateDescription": "可直接在 SQL 中使用模板变量,运行时会自动替换为 ISO 时间,兼容 SQLite 与 PostgreSQL。",
|
||||
"saving": "保存中...",
|
||||
"saveFailed": "保存看板失败",
|
||||
|
||||
Reference in New Issue
Block a user