Update documentation system: improve structure, search, and editor
This commit is contained in:
@@ -6736,7 +6736,7 @@ function backupUploadGuard(req, res, next) {
|
||||
async function buildBackupArchive() {
|
||||
const staging = fs.mkdtempSync(path.join(os.tmpdir(), 'wido-bk-'));
|
||||
try {
|
||||
const [g, s, e, st, pf, br, us, ub, gp, ep, md, sp, sl, pj, lr, lrv, al, nt, nr, bi, ct, cm, ca, sm, fb, uss, un, bm, sfr, pfcs, swm, ds, da, di, atr, sar] = await Promise.all([
|
||||
const [g, s, e, st, pf, br, us, ub, gp, ep, md, sp, sl, pj, lr, lrv, al, nt, nr, bi, ct, cm, ca, sm, fb, uss, un, bm, sfr, pfcs, swm, ds, da, di, df, atr, sar] = await Promise.all([
|
||||
pool.query('SELECT * FROM groups ORDER BY id'),
|
||||
pool.query('SELECT * FROM students ORDER BY id'),
|
||||
pool.query('SELECT * FROM entries ORDER BY id'),
|
||||
@@ -6771,6 +6771,7 @@ async function buildBackupArchive() {
|
||||
pool.query('SELECT * FROM doc_sections ORDER BY id'),
|
||||
pool.query('SELECT * FROM doc_articles ORDER BY id'),
|
||||
pool.query('SELECT * FROM doc_images ORDER BY id'),
|
||||
pool.query('SELECT * FROM doc_files ORDER BY id'),
|
||||
pool.query('SELECT * FROM achievement_types ORDER BY id'),
|
||||
pool.query('SELECT * FROM student_achievements ORDER BY id'),
|
||||
]);
|
||||
@@ -6793,10 +6794,12 @@ async function buildBackupArchive() {
|
||||
student_face_refs: sfr.rowCount, photo_faces: pfcs.rowCount, student_work_marks: swm.rowCount,
|
||||
achievement_types: atr.rowCount, student_achievements: sar.rowCount,
|
||||
doc_sections: ds.rowCount, doc_articles: da.rowCount, doc_images: di.rowCount,
|
||||
doc_files: df.rowCount,
|
||||
},
|
||||
groups: g.rows, students: s.rows, entries: e.rows, settings, project_files: pf.rows, branches: br.rows, users: us.rows, user_branches: ub.rows, group_photos: gp.rows, entry_photos: ep.rows, modules: md.rows, student_photos: sp.rows, share_links: sl.rows, photo_jobs: pj.rows, lesson_reports: lr.rows, lesson_report_versions: lrv.rows, audit_log: al.rows, notifications: nt.rows, notification_reads: nr.rows, banned_ips: bi.rows, chat_threads: ct.rows, chat_messages: cm.rows, chat_attachments: ca.rows, short_messages: sm.rows, feedbacks: fb.rows, user_settings: uss.rows, user_notes: un.rows, bookmarks: bm.rows, student_face_refs: sfr.rows, photo_faces: pfcs.rows, student_work_marks: swm.rows,
|
||||
achievement_types: atr.rows, student_achievements: sar.rows,
|
||||
doc_sections: ds.rows, doc_articles: da.rows, doc_images: di.rows,
|
||||
doc_files: df.rows,
|
||||
};
|
||||
fs.writeFileSync(path.join(staging, 'data.json'), JSON.stringify(payload));
|
||||
const files = await storage.downloadAll(path.join(staging, 'uploads'));
|
||||
@@ -7216,21 +7219,6 @@ app.post('/api/restore', requireAdmin, backupUploadGuard, uploadBackup.single('b
|
||||
[x.id, x.lesson_report_id, x.text, x.source || 'manual', x.author_id, x.created_at]
|
||||
);
|
||||
}
|
||||
for (const x of ndata.photo_jobs) {
|
||||
let ok = false;
|
||||
if (x.group_photo_id) {
|
||||
const gpx = await client.query('SELECT 1 FROM group_photos WHERE id = $1', [x.group_photo_id]);
|
||||
ok = !!gpx.rowCount;
|
||||
} else if (x.entry_id) {
|
||||
const ex = await client.query('SELECT 1 FROM entries WHERE id = $1', [x.entry_id]);
|
||||
ok = !!ex.rowCount;
|
||||
}
|
||||
if (!ok) continue;
|
||||
await client.query(
|
||||
'INSERT INTO photo_jobs (id, entry_id, group_photo_id, action, params, before_path, after_path, status, applied, attempts, error, created_at, finished_at) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)',
|
||||
[x.id, x.entry_id || null, x.group_photo_id || null, x.action, x.params, x.before_path, x.after_path, x.status, x.applied, x.attempts, x.error, x.created_at, x.finished_at]
|
||||
);
|
||||
}
|
||||
for (const x of ndata.project_files) {
|
||||
await client.query(
|
||||
'INSERT INTO project_files (id, entry_id, token, path, name, detached_at, created_at, size) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)',
|
||||
@@ -7249,6 +7237,21 @@ app.post('/api/restore', requireAdmin, backupUploadGuard, uploadBackup.single('b
|
||||
[x.id, x.entry_id, x.photo_path, x.caption, x.sort_order, x.face_scanned_at || null, x.face_img_width || null, x.face_img_height || null, x.created_at]
|
||||
);
|
||||
}
|
||||
for (const x of ndata.photo_jobs) {
|
||||
let ok = false;
|
||||
if (x.group_photo_id) {
|
||||
const gpx = await client.query('SELECT 1 FROM group_photos WHERE id = $1', [x.group_photo_id]);
|
||||
ok = !!gpx.rowCount;
|
||||
} else if (x.entry_id) {
|
||||
const ex = await client.query('SELECT 1 FROM entries WHERE id = $1', [x.entry_id]);
|
||||
ok = !!ex.rowCount;
|
||||
}
|
||||
if (!ok) continue;
|
||||
await client.query(
|
||||
'INSERT INTO photo_jobs (id, entry_id, group_photo_id, action, params, before_path, after_path, status, applied, attempts, error, created_at, finished_at) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)',
|
||||
[x.id, x.entry_id || null, x.group_photo_id || null, x.action, x.params, x.before_path, x.after_path, x.status, x.applied, x.attempts, x.error, x.created_at, x.finished_at]
|
||||
);
|
||||
}
|
||||
for (const x of (ndata.photo_faces || [])) {
|
||||
const tbl = x.source_type === 'entry' ? 'entry_photos' : 'group_photos';
|
||||
const ex = await client.query(`SELECT 1 FROM ${tbl} WHERE id = $1`, [x.source_id]);
|
||||
|
||||
Reference in New Issue
Block a user