.
This commit is contained in:
@@ -940,9 +940,42 @@ async function pollRescan(jobId) {
|
||||
}
|
||||
|
||||
// ── EDITOR ────────────────────────────
|
||||
function tsKey(v) {
|
||||
return v ? String(v) : '';
|
||||
}
|
||||
function rowId(r) {
|
||||
const n = Number(r && r.id);
|
||||
return Number.isFinite(n) ? n : 0;
|
||||
}
|
||||
function sortEditorRows(rows) {
|
||||
const fileTs = new Map();
|
||||
const fileId = new Map();
|
||||
(rows || []).forEach(r => {
|
||||
const f = (fileBase(r.source_file) || r.source_file || '').toLowerCase();
|
||||
const t = tsKey(r.processed_at) || tsKey(r.created_at) || tsKey(r.updated_at);
|
||||
if (t > (fileTs.get(f) || '')) fileTs.set(f, t);
|
||||
const id = rowId(r);
|
||||
if (id > (fileId.get(f) || 0)) fileId.set(f, id);
|
||||
});
|
||||
return [...(rows || [])].sort((a, b) => {
|
||||
const fa = (fileBase(a.source_file) || a.source_file || '').toLowerCase();
|
||||
const fb = (fileBase(b.source_file) || b.source_file || '').toLowerCase();
|
||||
const byFileTs = (fileTs.get(fb) || '').localeCompare(fileTs.get(fa) || '');
|
||||
if (byFileTs) return byFileTs;
|
||||
const byFileId = (fileId.get(fb) || 0) - (fileId.get(fa) || 0);
|
||||
if (byFileId) return byFileId;
|
||||
const sa = tsKey(a.created_at) || tsKey(a.updated_at);
|
||||
const sb = tsKey(b.created_at) || tsKey(b.updated_at);
|
||||
const bySec = sb.localeCompare(sa);
|
||||
if (bySec) return bySec;
|
||||
return rowId(b) - rowId(a);
|
||||
});
|
||||
}
|
||||
|
||||
function renderEditor(rows) {
|
||||
const tbody = document.getElementById('editor-body');
|
||||
tbody.innerHTML = rows.map(r => `
|
||||
const sorted = sortEditorRows(rows);
|
||||
tbody.innerHTML = sorted.map(r => `
|
||||
<tr>
|
||||
<td><span class="code-badge">${r.code}</span></td>
|
||||
<td class="title-cell">${esc(r.title)}</td>
|
||||
@@ -967,7 +1000,7 @@ function renderEditor(rows) {
|
||||
<td style="font-size:11px;color:var(--muted);font-family:var(--mono);white-space:nowrap">${r.updated_at}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
document.getElementById('editor-stats').textContent = rows.length + ' реда';
|
||||
document.getElementById('editor-stats').textContent = sorted.length + ' реда';
|
||||
}
|
||||
|
||||
function filterEditor() {
|
||||
|
||||
Reference in New Issue
Block a user