chore(demo): move to right directory

This commit is contained in:
Elian Doran
2025-05-27 18:34:04 +03:00
parent 7cb4cc8469
commit 099e73b114
173 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<div style="padding: 20px">
<p>This table shows 100 largest notes, including their revisions and attachments.</p>
<table class="table stats-table" style="font-size: 90%;">
<tr>
<th>Note</th>
<th nowrap>Size</th>
</tr>
</table>
</div>

View File

@@ -0,0 +1,47 @@
const notes = await api.runOnBackend(() => {
const blobSizes = api.sql.getMap(`SELECT blobId, LENGTH(content) FROM blobs`);
const noteBlobIds = api.sql.getRows(`
SELECT
notes.noteId,
notes.blobId,
GROUP_CONCAT(revisions.blobId) AS revisions_blobIds,
GROUP_CONCAT(note_attachments.blobId) AS note_attachments_blobIds,
GROUP_CONCAT(revision_attachments.blobId) AS revision_attachments_blobIds
FROM
notes
LEFT JOIN revisions USING (noteId)
LEFT JOIN attachments AS note_attachments ON notes.noteId = note_attachments.ownerId
LEFT JOIN attachments AS revision_attachments ON revisions.revisionId = revision_attachments.ownerId
GROUP BY noteId`);
let noteSizes = [];
for (const {noteId, blobId, revisions_blobIds, note_attachments_blobIds, revision_attachments_blobIds} of noteBlobIds) {
const blobIds = new Set(`${blobId},${revisions_blobIds},${note_attachments_blobIds},${revision_attachments_blobIds}`.split(',').filter(blobId => !!blobId));
const lengths = [...blobIds].map(blobId => blobSizes[blobId] || 0);
const totalLength = lengths.reduce((partialSum, a) => partialSum + a, 0);
noteSizes.push({ noteId, size: totalLength });
}
noteSizes.sort((a, b) => a.size > b.size ? -1 : 1);
noteSizes = noteSizes.splice(0, 100);
return noteSizes;
});
const $statsTable = api.$container.find('.stats-table');
for (const note of notes) {
$statsTable.append(
$("<tr>")
.append(
$("<td>").append(await api.createNoteLink(note.noteId, {showNotePath: true}))
)
.append(
$("<td nowrap>").text(note.size + " bytes")
)
);
}