mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
generate document now creates also labels and relations
This commit is contained in:
parent
07b3d11fe5
commit
29c5e394ab
@ -117,7 +117,7 @@ async function createNewNote(parentNoteId, noteData) {
|
|||||||
isExpanded: !!noteData.isExpanded
|
isExpanded: !!noteData.isExpanded
|
||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
for (const attr of await parentNote.getAttributes()) {
|
for (const attr of await parentNote.getOwnedAttributes()) {
|
||||||
if (attr.name.startsWith("child:")) {
|
if (attr.name.startsWith("child:")) {
|
||||||
await new Attribute({
|
await new Attribute({
|
||||||
noteId: note.noteId,
|
noteId: note.noteId,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
require('../entities/entity_constructor');
|
require('../entities/entity_constructor');
|
||||||
const sqlInit = require('../services/sql_init');
|
const sqlInit = require('../services/sql_init');
|
||||||
const noteService = require('../services/notes');
|
const noteService = require('../services/notes');
|
||||||
|
const attributeService = require('../services/attributes');
|
||||||
const cls = require('../services/cls');
|
const cls = require('../services/cls');
|
||||||
const cloningService = require('../services/cloning');
|
const cloningService = require('../services/cloning');
|
||||||
const loremIpsum = require('lorem-ipsum').loremIpsum;
|
const loremIpsum = require('lorem-ipsum').loremIpsum;
|
||||||
@ -19,7 +20,7 @@ if (!noteCount) {
|
|||||||
|
|
||||||
const notes = ['root'];
|
const notes = ['root'];
|
||||||
|
|
||||||
function getRandomParentNoteId() {
|
function getRandomNoteId() {
|
||||||
const index = Math.floor(Math.random() * notes.length);
|
const index = Math.floor(Math.random() * notes.length);
|
||||||
|
|
||||||
return notes[index];
|
return notes[index];
|
||||||
@ -33,17 +34,17 @@ async function start() {
|
|||||||
const content = loremIpsum({ count: paragraphCount, units: 'paragraphs', sentenceLowerBound: 1, sentenceUpperBound: 15,
|
const content = loremIpsum({ count: paragraphCount, units: 'paragraphs', sentenceLowerBound: 1, sentenceUpperBound: 15,
|
||||||
paragraphLowerBound: 3, paragraphUpperBound: 10, format: 'html' });
|
paragraphLowerBound: 3, paragraphUpperBound: 10, format: 'html' });
|
||||||
|
|
||||||
const {note} = await noteService.createNote(getRandomParentNoteId(), title, content);
|
const {note} = await noteService.createNote(getRandomNoteId(), title, content);
|
||||||
|
|
||||||
console.log(`Created note ${i}: ${title}`);
|
console.log(`Created note ${i}: ${title}`);
|
||||||
|
|
||||||
notes.push(note.noteId);
|
notes.push(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we'll create clones for 20% of notes
|
// we'll create clones for 4% of notes
|
||||||
for (let i = 0; i < (noteCount / 50); i++) {
|
for (let i = 0; i < (noteCount / 25); i++) {
|
||||||
const noteIdToClone = getRandomParentNoteId();
|
const noteIdToClone = getRandomNoteId();
|
||||||
const parentNoteId = getRandomParentNoteId();
|
const parentNoteId = getRandomNoteId();
|
||||||
const prefix = Math.random() > 0.8 ? "prefix" : null;
|
const prefix = Math.random() > 0.8 ? "prefix" : null;
|
||||||
|
|
||||||
const result = await cloningService.cloneNoteToParent(noteIdToClone, parentNoteId, prefix);
|
const result = await cloningService.cloneNoteToParent(noteIdToClone, parentNoteId, prefix);
|
||||||
@ -51,6 +52,30 @@ async function start() {
|
|||||||
console.log(`Cloning ${i}:`, result.success ? "succeeded" : "FAILED");
|
console.log(`Cloning ${i}:`, result.success ? "succeeded" : "FAILED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < noteCount; i++) {
|
||||||
|
await attributeService.createAttribute({
|
||||||
|
noteId: getRandomNoteId(),
|
||||||
|
type: 'label',
|
||||||
|
name: 'label',
|
||||||
|
value: 'value',
|
||||||
|
isInheritable: Math.random() > 0.1 // 10% are inheritable
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Creating label ${i}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < noteCount; i++) {
|
||||||
|
await attributeService.createAttribute({
|
||||||
|
noteId: getRandomNoteId(),
|
||||||
|
type: 'relation',
|
||||||
|
name: 'relation',
|
||||||
|
value: getRandomNoteId(),
|
||||||
|
isInheritable: Math.random() > 0.1 // 10% are inheritable
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Creating relation ${i}`);
|
||||||
|
}
|
||||||
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user