n8n 連携: 後回しにした小さな問題 4 件を修正
- タスク名・チェックの変更で画面全体を作り直さない (直後のクリックが失われていた) - チケット選択の番号もエスケープする - 長さ 0 分・24 時間超の区間は送れない理由を付け、画面でも送信でも外す - items に dict でない項目があっても 500 にせず、その項目のエラーにする Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+14
@@ -1220,6 +1220,7 @@ N8N_CONFIG = APP_DIR / "n8n.json"
|
||||
N8N_GAP_MIN = 30 # この分数以上の空きで作業区間を切る
|
||||
N8N_MIN_MIN = 5 # この分数未満の区間は一覧に出さない
|
||||
N8N_MAX_DAYS = 62 # n8n の wt-import-rows と同じ上限
|
||||
N8N_MAX_BLOCK_SEC = 24 * 3600 # n8n の wt-import が受け付ける区間の長さの上限
|
||||
N8N_STALE_SEC = 24 * 3600 # ログがこれだけ更新されていなければ、待ちのままでも進行中とみなさない
|
||||
|
||||
|
||||
@@ -1268,6 +1269,12 @@ def make_blocks(session, gap_min=N8N_GAP_MIN, min_min=N8N_MIN_MIN, now=None):
|
||||
minutes = (group["end"] - group["start"]) / 60.0
|
||||
if minutes < min_min and not in_progress:
|
||||
continue
|
||||
# n8n の受け口が断る長さは、ここで送れない理由として付けておく
|
||||
problem = None
|
||||
if group["end"] <= group["start"]:
|
||||
problem = "長さが 0 分です"
|
||||
elif group["end"] - group["start"] > N8N_MAX_BLOCK_SEC:
|
||||
problem = "24 時間を超えています"
|
||||
out.append(
|
||||
{
|
||||
"source": block_source(session["id"], group["start"]),
|
||||
@@ -1280,6 +1287,7 @@ def make_blocks(session, gap_min=N8N_GAP_MIN, min_min=N8N_MIN_MIN, now=None):
|
||||
"minutes": int(round(minutes)),
|
||||
"turns": group["turns"],
|
||||
"inProgress": in_progress,
|
||||
"problem": problem,
|
||||
}
|
||||
)
|
||||
return out
|
||||
@@ -1545,6 +1553,9 @@ def n8n_send(store, holder, payload, now=None):
|
||||
gap, minimum = holder.settings()
|
||||
rows, errors, cache = [], [], {}
|
||||
for item in items:
|
||||
if not isinstance(item, dict):
|
||||
errors.append({"source": "", "error": "項目の形が不正です"})
|
||||
continue
|
||||
source = str(item.get("source") or "")
|
||||
task = " ".join(str(item.get("task") or "").split())
|
||||
match = SOURCE_RE.match(source)
|
||||
@@ -1570,6 +1581,9 @@ def n8n_send(store, holder, payload, now=None):
|
||||
if block["inProgress"]:
|
||||
errors.append({"source": source, "error": "進行中の区間は送れません"})
|
||||
continue
|
||||
if block["problem"]:
|
||||
errors.append({"source": source, "error": block["problem"]})
|
||||
continue
|
||||
rows.append({"source": source, "date": block["date"], "start_time": block["start"],
|
||||
"end_time": block["end"], "task": task, "memo": str(item.get("memo") or "")})
|
||||
result = {"ok": False, "inserted": [], "skipped": [], "errors": errors}
|
||||
|
||||
Reference in New Issue
Block a user