opencode-windows-scheduler 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -7
- package/README.md +14 -4
- package/README.ru.md +14 -4
- package/ROADMAP.md +30 -20
- package/dist/core/analytics.d.ts +129 -0
- package/dist/core/analytics.d.ts.map +1 -0
- package/dist/core/analytics.js +286 -0
- package/dist/core/dry-run.d.ts +13 -0
- package/dist/core/dry-run.d.ts.map +1 -1
- package/dist/core/dry-run.js +30 -0
- package/dist/core/matrix.d.ts.map +1 -1
- package/dist/core/matrix.js +10 -0
- package/dist/core/ps-wrapper.d.ts +32 -2
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +101 -3
- package/dist/core/retention.d.ts +29 -0
- package/dist/core/retention.d.ts.map +1 -0
- package/dist/core/retention.js +98 -0
- package/dist/core/schedule-gate.d.ts +2 -0
- package/dist/core/schedule-gate.d.ts.map +1 -0
- package/dist/core/schedule-gate.js +182 -0
- package/dist/core/schedule-v2.d.ts +88 -0
- package/dist/core/schedule-v2.d.ts.map +1 -0
- package/dist/core/schedule-v2.js +496 -0
- package/dist/core/scheduler/types.d.ts +15 -0
- package/dist/core/scheduler/types.d.ts.map +1 -1
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +13 -1
- package/dist/core/wrappers/bash.d.ts +15 -0
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +44 -1
- package/dist/db/history-repo.d.ts +41 -0
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +78 -0
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +11 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1094 -56
- package/dist/notifications.d.ts +112 -6
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +396 -34
- package/dist/profiles.d.ts +60 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +209 -0
- package/dist/rpc.d.ts +645 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +251 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +200 -7
- package/dist/settings.d.ts +80 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +159 -8
- package/dist/task-transfer.d.ts +13 -0
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -11
- package/dist/version.d.ts +8 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +27 -0
- package/dist/workspaces.d.ts +43 -0
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +174 -8
- package/docs/ARCHITECTURE.md +45 -13
- package/docs/FEATURES.md +103 -12
- package/gui-experimental.cjs +4 -2
- package/package.json +8 -2
- package/src/core/analytics.ts +414 -0
- package/src/core/dry-run.ts +42 -0
- package/src/core/matrix.ts +10 -0
- package/src/core/ps-wrapper.ts +117 -3
- package/src/core/retention.ts +141 -0
- package/src/core/schedule-gate.ts +213 -0
- package/src/core/schedule-v2.ts +533 -0
- package/src/core/scheduler/types.ts +15 -0
- package/src/core/scheduler/windows.ts +13 -1
- package/src/core/wrappers/bash.ts +60 -0
- package/src/db/history-repo.ts +116 -0
- package/src/db/schema.ts +14 -0
- package/src/gui.tsx +3613 -2725
- package/src/index.ts +1325 -55
- package/src/notifications.ts +516 -40
- package/src/profiles.ts +236 -0
- package/src/rpc.ts +267 -2
- package/src/server.ts +226 -7
- package/src/settings.ts +285 -9
- package/src/task-transfer.ts +44 -0
- package/src/types.ts +3 -13
- package/src/version.ts +27 -0
- package/src/workspaces.ts +214 -8
- package/dist/gui-experimental.cjs +0 -1
package/src/server.ts
CHANGED
|
@@ -3,9 +3,13 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import { execFile } from "node:child_process";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { loadHistory, loadMetrics } from "./history.js";
|
|
6
|
+
import { getHistory, countRunningRecords } from "./db/history-repo.js";
|
|
7
|
+
import { buildAnalytics, historyToCsv } from "./core/analytics.js";
|
|
6
8
|
import { getSchedulerTitle } from "./core/scheduler/index.js";
|
|
9
|
+
import { getPluginVersion } from "./version.js";
|
|
7
10
|
import { checkpointDb, getDbFile, getDbStatus } from "./db/index.js";
|
|
8
11
|
import { listWorkspaces } from "./workspaces.js";
|
|
12
|
+
import { getProfileName, getProfilePort } from "./profiles.js";
|
|
9
13
|
import { simulatePipeline } from "./core/dry-run.js";
|
|
10
14
|
|
|
11
15
|
/**
|
|
@@ -252,7 +256,8 @@ export async function startDashboardServer(
|
|
|
252
256
|
if (running) return { port: running.port };
|
|
253
257
|
if (starting) return starting;
|
|
254
258
|
|
|
255
|
-
|
|
259
|
+
// Спринт 21: у профиля может быть свой порт (profile.json / OPENCODE_SCHEDULER_PORT).
|
|
260
|
+
const preferred = ports?.preferred ?? getProfilePort(getProfileName()) ?? PREFERRED_PORT;
|
|
256
261
|
const fallback = ports?.fallback ?? FALLBACK_PORT;
|
|
257
262
|
// Последний кандидат — порт 0: ОС сама выдаст гарантированно свободный порт.
|
|
258
263
|
const candidates = ports
|
|
@@ -491,6 +496,8 @@ async function handleRequest(
|
|
|
491
496
|
pathname === "/api/history" ||
|
|
492
497
|
pathname === "/api/metrics" ||
|
|
493
498
|
pathname === "/api/models-analysis" ||
|
|
499
|
+
pathname === "/api/analytics" ||
|
|
500
|
+
pathname === "/api/history/export" ||
|
|
494
501
|
pathname === "/api/export-db" ||
|
|
495
502
|
pathname === "/api/workspaces" ||
|
|
496
503
|
pathname === "/api/health" ||
|
|
@@ -518,6 +525,10 @@ async function handleRequest(
|
|
|
518
525
|
ok: true,
|
|
519
526
|
app: DASHBOARD_MARKER,
|
|
520
527
|
port: getDashboardPort(),
|
|
528
|
+
version: getPluginVersion(),
|
|
529
|
+
scheduler: getSchedulerTitle(),
|
|
530
|
+
profile: getProfileName(),
|
|
531
|
+
queueDepth: countRunningRecords(),
|
|
521
532
|
db: getDbStatus(),
|
|
522
533
|
});
|
|
523
534
|
return;
|
|
@@ -618,6 +629,59 @@ async function handleRequest(
|
|
|
618
629
|
return;
|
|
619
630
|
}
|
|
620
631
|
|
|
632
|
+
// Аналитика за период (Спринт 18): итоги, дневные бакеты, топ по стоимости.
|
|
633
|
+
if (req.method === "GET" && pathname === "/api/analytics") {
|
|
634
|
+
const days = Math.min(
|
|
635
|
+
365,
|
|
636
|
+
Math.max(1, Math.floor(Number(url.searchParams.get("days")) || 14))
|
|
637
|
+
);
|
|
638
|
+
const topLimit = Math.max(
|
|
639
|
+
1,
|
|
640
|
+
Math.floor(Number(url.searchParams.get("top")) || 10)
|
|
641
|
+
);
|
|
642
|
+
const records = getHistory(null, 20000);
|
|
643
|
+
const tasks = await deps.getTasks();
|
|
644
|
+
const report = buildAnalytics(records, {
|
|
645
|
+
days,
|
|
646
|
+
topLimit,
|
|
647
|
+
tasks: tasks.map((task) => ({
|
|
648
|
+
name: task.name,
|
|
649
|
+
matrixParentId: task.matrixParentId ?? null,
|
|
650
|
+
})),
|
|
651
|
+
});
|
|
652
|
+
sendJson(res, 200, report);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Экспорт истории: CSV (для Excel) или JSON (для скриптов).
|
|
657
|
+
if (req.method === "GET" && pathname === "/api/history/export") {
|
|
658
|
+
const format = (url.searchParams.get("format") || "csv").toLowerCase();
|
|
659
|
+
if (format !== "csv" && format !== "json") {
|
|
660
|
+
sendJson(res, 400, { error: "Неподдерживаемый формат экспорта. Допустимые: csv, json." });
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
const records = getHistory(null, 100000);
|
|
664
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
665
|
+
if (format === "json") {
|
|
666
|
+
sendAttachment(
|
|
667
|
+
res,
|
|
668
|
+
200,
|
|
669
|
+
"application/json; charset=utf-8",
|
|
670
|
+
JSON.stringify({ exportedAt: new Date().toISOString(), records }, null, 2),
|
|
671
|
+
`history-${stamp}.json`
|
|
672
|
+
);
|
|
673
|
+
} else {
|
|
674
|
+
sendAttachment(
|
|
675
|
+
res,
|
|
676
|
+
200,
|
|
677
|
+
"text/csv; charset=utf-8",
|
|
678
|
+
historyToCsv(records),
|
|
679
|
+
`history-${stamp}.csv`
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
|
|
621
685
|
if (req.method === "GET" && (pathname === "/api/metrics" || pathname === "/api/summary")) {
|
|
622
686
|
const metrics = await loadMetrics();
|
|
623
687
|
// Токены и стоимость суммируем по history.json (как требует спринт):
|
|
@@ -822,6 +886,29 @@ function sendBuffer(
|
|
|
822
886
|
res.end(body);
|
|
823
887
|
}
|
|
824
888
|
|
|
889
|
+
/** Отправляет текстовый файл (CSV/JSON-экспорт истории). */
|
|
890
|
+
function sendAttachment(
|
|
891
|
+
res: http.ServerResponse,
|
|
892
|
+
status: number,
|
|
893
|
+
contentType: string,
|
|
894
|
+
body: string,
|
|
895
|
+
filename: string
|
|
896
|
+
): void {
|
|
897
|
+
if (res.headersSent) {
|
|
898
|
+
res.end();
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
res.writeHead(status, {
|
|
902
|
+
"Content-Type": contentType,
|
|
903
|
+
"Content-Length": String(Buffer.byteLength(body, "utf8")),
|
|
904
|
+
"Content-Disposition": `attachment; filename="${filename}"`,
|
|
905
|
+
"Cache-Control": "no-store",
|
|
906
|
+
"X-Content-Type-Options": "nosniff",
|
|
907
|
+
[DASHBOARD_HEADER]: DASHBOARD_MARKER,
|
|
908
|
+
});
|
|
909
|
+
res.end(body);
|
|
910
|
+
}
|
|
911
|
+
|
|
825
912
|
/**
|
|
826
913
|
* Список задач + метрики по каждой задаче, посчитанные из history.json
|
|
827
914
|
* (колонка «Метрики» в таблице дашборда).
|
|
@@ -918,6 +1005,24 @@ function renderPage(): string {
|
|
|
918
1005
|
.prio { font-size: 12px; color: #f5a623; white-space: nowrap; }
|
|
919
1006
|
.hist { margin-top: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
|
|
920
1007
|
.hist h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
|
|
1008
|
+
.an-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
|
1009
|
+
.an-actions { display: flex; gap: 6px; }
|
|
1010
|
+
.an-actions .btn { padding: 3px 8px; font-size: 11px; }
|
|
1011
|
+
.an-kpis { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
|
|
1012
|
+
.an-kpis b { color: var(--text); font-size: 14px; }
|
|
1013
|
+
.an-chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 6px 0 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
|
|
1014
|
+
.an-bar { flex: 1 1 0; min-width: 14px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: default; }
|
|
1015
|
+
.an-bar-fill { width: 100%; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .85; }
|
|
1016
|
+
.an-label { font-size: 9px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
|
|
1017
|
+
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 14px; }
|
|
1018
|
+
.an-grid h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
|
|
1019
|
+
.an-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
1020
|
+
.an-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 3px 6px; border-bottom: 1px solid var(--border); }
|
|
1021
|
+
.an-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); color: var(--text); }
|
|
1022
|
+
.an-table tr:last-child td { border-bottom: none; }
|
|
1023
|
+
.an-rate.okr { color: var(--ok); }
|
|
1024
|
+
.an-rate.midr { color: var(--run); }
|
|
1025
|
+
.an-rate.errr { color: var(--err); }
|
|
921
1026
|
.hist-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
|
|
922
1027
|
.hist-row:last-child { border-bottom: none; }
|
|
923
1028
|
.hist-time { color: var(--muted); white-space: nowrap; }
|
|
@@ -926,8 +1031,7 @@ function renderPage(): string {
|
|
|
926
1031
|
.hist-hook { white-space: nowrap; }
|
|
927
1032
|
.hist-hook.okh { color: #34c759; }
|
|
928
1033
|
.hist-hook.errh { color: #ff3b30; }
|
|
929
|
-
.whatif-text { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
|
|
930
|
-
.whatif-text b { color: var(--text); }
|
|
1034
|
+
.whatif-text { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; } .whatif-text b { color: var(--text); }
|
|
931
1035
|
.wi-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
932
1036
|
.wi-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
|
|
933
1037
|
.wi-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); color: var(--text); }
|
|
@@ -974,7 +1078,7 @@ function renderPage(): string {
|
|
|
974
1078
|
<header>
|
|
975
1079
|
<div>
|
|
976
1080
|
<h1>❄️ ${getSchedulerTitle()} ❄️</h1>
|
|
977
|
-
<div class="sub">Локальный веб-дашборд · Local AI CI/CD Orchestrator</div>
|
|
1081
|
+
<div class="sub">Локальный веб-дашборд · Local AI CI/CD Orchestrator · профиль <b>${getProfileName()}</b></div>
|
|
978
1082
|
</div>
|
|
979
1083
|
<div style="text-align:right">
|
|
980
1084
|
<a class="btn btn-db" href="/api/export-db" download>💾 Скачать БД</a>
|
|
@@ -1018,6 +1122,22 @@ function renderPage(): string {
|
|
|
1018
1122
|
<div id="history"><div class="empty">Загрузка…</div></div>
|
|
1019
1123
|
</div>
|
|
1020
1124
|
|
|
1125
|
+
<div class="hist">
|
|
1126
|
+
<div class="an-head">
|
|
1127
|
+
<h2>📊 Аналитика за период</h2>
|
|
1128
|
+
<div class="an-actions">
|
|
1129
|
+
<a class="btn" href="/api/history/export?format=csv" download>⬇️ CSV</a>
|
|
1130
|
+
<a class="btn" href="/api/history/export?format=json" download>⬇️ JSON</a>
|
|
1131
|
+
</div>
|
|
1132
|
+
</div>
|
|
1133
|
+
<div class="an-kpis" id="an-kpis"><span>Загрузка…</span></div>
|
|
1134
|
+
<div class="an-chart" id="an-chart"></div>
|
|
1135
|
+
<div class="an-grid">
|
|
1136
|
+
<div><h3>Топ задач по стоимости</h3><div id="an-top"></div></div>
|
|
1137
|
+
<div><h3>Матрицы</h3><div id="an-matrices"></div></div>
|
|
1138
|
+
</div>
|
|
1139
|
+
</div>
|
|
1140
|
+
|
|
1021
1141
|
<div class="hist">
|
|
1022
1142
|
<h2>📊 What-If: Анализ моделей</h2>
|
|
1023
1143
|
<div id="whatif-table"><div class="empty">Загрузка…</div></div>
|
|
@@ -1212,8 +1332,105 @@ function renderPage(): string {
|
|
|
1212
1332
|
box.innerHTML = html;
|
|
1213
1333
|
}
|
|
1214
1334
|
|
|
1215
|
-
function
|
|
1216
|
-
|
|
1335
|
+
function rateClass(rate) {
|
|
1336
|
+
if (rate >= 90) return 'okr';
|
|
1337
|
+
if (rate >= 60) return 'midr';
|
|
1338
|
+
return 'errr';
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
function money(value) {
|
|
1342
|
+
var n = Number(value) || 0;
|
|
1343
|
+
return '$' + n.toFixed(n >= 1 ? 2 : 4);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
function durationText(ms) {
|
|
1347
|
+
var n = Number(ms) || 0;
|
|
1348
|
+
if (n <= 0) return '—';
|
|
1349
|
+
if (n < 1000) return n + ' мс';
|
|
1350
|
+
if (n < 60000) return (n / 1000).toFixed(1) + ' с';
|
|
1351
|
+
return Math.round(n / 60000) + ' мин';
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
function renderAnalytics(an) {
|
|
1355
|
+
var kpis = document.getElementById('an-kpis');
|
|
1356
|
+
var chart = document.getElementById('an-chart');
|
|
1357
|
+
var top = document.getElementById('an-top');
|
|
1358
|
+
var matrices = document.getElementById('an-matrices');
|
|
1359
|
+
if (!kpis || !chart || !top || !matrices) return;
|
|
1360
|
+
|
|
1361
|
+
if (!an || !an.totals) {
|
|
1362
|
+
kpis.innerHTML = '<span>Аналитика недоступна.</span>';
|
|
1363
|
+
chart.innerHTML = '';
|
|
1364
|
+
top.innerHTML = '<div class="empty" style="padding:10px">—</div>';
|
|
1365
|
+
matrices.innerHTML = '<div class="empty" style="padding:10px">—</div>';
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
var t = an.totals;
|
|
1370
|
+
kpis.innerHTML =
|
|
1371
|
+
'<span>Запусков: <b>' + t.total + '</b></span>' +
|
|
1372
|
+
'<span>Успех: <b class="an-rate ' + rateClass(t.successRate) + '">' + t.successRate + '%</b></span>' +
|
|
1373
|
+
'<span>Средняя длительность: <b>' + durationText(t.avgDurationMs) + '</b></span>' +
|
|
1374
|
+
'<span>Токены: <b>' + Number(t.tokens || 0).toLocaleString('ru-RU') + '</b></span>' +
|
|
1375
|
+
'<span>Стоимость: <b>' + money(t.costUsd) + '</b></span>' +
|
|
1376
|
+
'<span>Окно: <b>' + an.windowDays + ' дн.</b></span>' +
|
|
1377
|
+
(t.partial ? '<span>Частично: <b>' + t.partial + '</b></span>' : '');
|
|
1378
|
+
|
|
1379
|
+
var daily = an.daily || [];
|
|
1380
|
+
var max = 1;
|
|
1381
|
+
for (var i = 0; i < daily.length; i++) {
|
|
1382
|
+
if (daily[i].total > max) max = daily[i].total;
|
|
1383
|
+
}
|
|
1384
|
+
var bars = '';
|
|
1385
|
+
for (var j = 0; j < daily.length; j++) {
|
|
1386
|
+
var d = daily[j];
|
|
1387
|
+
var h = d.total > 0 ? Math.max(3, Math.round((d.total / max) * 92)) : 2;
|
|
1388
|
+
var color = d.total === 0 ? 'var(--border)' : (d.error > 0 ? 'var(--err)' : 'var(--ok)');
|
|
1389
|
+
var tip = d.date + ': всего ' + d.total + ', успех ' + d.success + ', ошибок ' + d.error + ', ' + money(d.costUsd);
|
|
1390
|
+
bars += '<div class="an-bar" title="' + esc(tip) + '">' +
|
|
1391
|
+
'<div class="an-bar-fill" style="height:' + h + '%' + ';background:' + esc(color) + '"></div>' +
|
|
1392
|
+
'<div class="an-label">' + esc(String(d.date).slice(5)) + '</div>' +
|
|
1393
|
+
'</div>';
|
|
1394
|
+
}
|
|
1395
|
+
chart.innerHTML = bars || '<div class="empty" style="padding:10px">Нет данных за период.</div>';
|
|
1396
|
+
|
|
1397
|
+
var topRows = an.topByCost || [];
|
|
1398
|
+
if (topRows.length === 0) {
|
|
1399
|
+
top.innerHTML = '<div class="empty" style="padding:10px">Нет запусков за период.</div>';
|
|
1400
|
+
} else {
|
|
1401
|
+
var html = '<table class="an-table"><thead><tr><th>Задача</th><th>Запусков</th><th>Успех</th><th>Стоимость</th></tr></thead><tbody>';
|
|
1402
|
+
for (var k = 0; k < topRows.length; k++) {
|
|
1403
|
+
var row = topRows[k];
|
|
1404
|
+
html += '<tr>' +
|
|
1405
|
+
'<td>' + (row.isMatrixClone ? '↳ ' : '') + esc(row.taskName) + '</td>' +
|
|
1406
|
+
'<td>' + row.total + '</td>' +
|
|
1407
|
+
'<td class="an-rate ' + rateClass(row.successRate) + '">' + row.successRate + '%</td>' +
|
|
1408
|
+
'<td>' + money(row.costUsd) + '</td>' +
|
|
1409
|
+
'</tr>';
|
|
1410
|
+
}
|
|
1411
|
+
top.innerHTML = html + '</tbody></table>';
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
var matrixRows = an.matrices || [];
|
|
1415
|
+
if (matrixRows.length === 0) {
|
|
1416
|
+
matrices.innerHTML = '<div class="empty" style="padding:10px">Матриц за период не запускалось.</div>';
|
|
1417
|
+
} else {
|
|
1418
|
+
var mhtml = '<table class="an-table"><thead><tr><th>Матрица</th><th>Клонов</th><th>Запусков</th><th>Успех</th><th>Стоимость</th></tr></thead><tbody>';
|
|
1419
|
+
for (var q = 0; q < matrixRows.length; q++) {
|
|
1420
|
+
var m = matrixRows[q];
|
|
1421
|
+
mhtml += '<tr>' +
|
|
1422
|
+
'<td>📦 ' + esc(m.parentId) + '</td>' +
|
|
1423
|
+
'<td>' + m.clones + '</td>' +
|
|
1424
|
+
'<td>' + m.total + '</td>' +
|
|
1425
|
+
'<td class="an-rate ' + rateClass(m.successRate) + '">' + m.successRate + '%</td>' +
|
|
1426
|
+
'<td>' + money(m.costUsd) + '</td>' +
|
|
1427
|
+
'</tr>';
|
|
1428
|
+
}
|
|
1429
|
+
matrices.innerHTML = mhtml + '</tbody></table>';
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
function renderModelsAnalysis(data) { var box = document.getElementById('whatif-table');
|
|
1217
1434
|
var text = document.getElementById('whatif-text');
|
|
1218
1435
|
if (!box || !text) return;
|
|
1219
1436
|
var models = (data && data.models) || [];
|
|
@@ -1455,7 +1672,8 @@ function renderPage(): string {
|
|
|
1455
1672
|
loadMetricsJson(),
|
|
1456
1673
|
safeJson('/api/history', { records: [] }),
|
|
1457
1674
|
safeJson('/api/models-analysis', { models: [], totals: {}, whatIf: [] }),
|
|
1458
|
-
safeJson('/api/workspaces', { workspaces: [] })
|
|
1675
|
+
safeJson('/api/workspaces', { workspaces: [] }),
|
|
1676
|
+
safeJson('/api/analytics?days=14', null)
|
|
1459
1677
|
]);
|
|
1460
1678
|
var tasks = (results[0] && results[0].tasks) || [];
|
|
1461
1679
|
var m = results[1] || {};
|
|
@@ -1474,6 +1692,7 @@ function renderPage(): string {
|
|
|
1474
1692
|
renderGraph(tasks);
|
|
1475
1693
|
renderHistory(history);
|
|
1476
1694
|
renderModelsAnalysis(modelsAnalysis);
|
|
1695
|
+
renderAnalytics(results[5]);
|
|
1477
1696
|
showServerWarn(results[0] ? null : 'Не удалось загрузить список задач — остальные блоки обновлены. Подробности в консоли (F12).');
|
|
1478
1697
|
updated.textContent = 'Обновлено: ' + new Date().toLocaleTimeString();
|
|
1479
1698
|
} catch (err) {
|