diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml index fc31b6b2f..6cc1e5572 100644 --- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml +++ b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml @@ -57,7 +57,6 @@ 1 apiTokenId - 1 @@ -126,21 +125,17 @@ 1 attributeId - 1 noteId - name value - value - attributeId @@ -202,17 +197,14 @@ value 1 branchId - 1 noteId parentNoteId - parentNoteId - branchId @@ -243,7 +235,6 @@ parentNoteId 1 noteId - 1 @@ -274,7 +265,6 @@ parentNoteId 1 noteRevisionId - 1 @@ -359,28 +349,22 @@ parentNoteId 1 noteRevisionId - 1 noteId - utcDateLastEdited - utcDateCreated - dateLastEdited - dateCreated - noteRevisionId @@ -462,36 +446,28 @@ parentNoteId 1 noteId - 1 title - type - isDeleted - dateCreated - dateModified - utcDateCreated - utcDateModified - noteId @@ -532,7 +508,6 @@ parentNoteId 1 name - 1 @@ -568,7 +543,6 @@ parentNoteId 1 noteId - 1 @@ -589,12 +563,10 @@ parentNoteId 1 sourceId - 1 utcDateCreated - sourceId @@ -656,12 +628,10 @@ parentNoteId entityName entityId - 1 utcSyncDate - id diff --git a/src/tools/generate_document.js b/src/tools/generate_document.js index 2d0613755..4d5f7b11e 100644 --- a/src/tools/generate_document.js +++ b/src/tools/generate_document.js @@ -9,6 +9,8 @@ const noteService = require('../services/notes'); const attributeService = require('../services/attributes'); const cls = require('../services/cls'); const cloningService = require('../services/cloning'); +const repository = require('../services/repository'); +const noteRevisionService = require('../services/note_revisions'); const loremIpsum = require('lorem-ipsum').loremIpsum; const noteCount = parseInt(process.argv[2]); @@ -28,11 +30,23 @@ function getRandomNoteId() { async function start() { for (let i = 0; i < noteCount; i++) { - const title = loremIpsum({ count: 1, units: 'sentences', sentenceLowerBound: 1, sentenceUpperBound: 10 }); + const title = loremIpsum({ + count: 1, + units: 'sentences', + sentenceLowerBound: 1, + sentenceUpperBound: 10 + }); const paragraphCount = Math.floor(Math.random() * Math.random() * 100); - const content = loremIpsum({ count: paragraphCount, units: 'paragraphs', sentenceLowerBound: 1, sentenceUpperBound: 15, - paragraphLowerBound: 3, paragraphUpperBound: 10, format: 'html' }); + const content = loremIpsum({ + count: paragraphCount, + units: 'paragraphs', + sentenceLowerBound: 1, + sentenceUpperBound: 15, + paragraphLowerBound: 3, + paragraphUpperBound: 10, + format: 'html' + }); const {note} = await noteService.createNewNote({ parentNoteId: getRandomNoteId(), @@ -43,21 +57,17 @@ async function start() { console.log(`Created note ${i}: ${title}`); - notes.push(note.noteId); - } + if (Math.random() < 0.04) { + const noteIdToClone = note.noteId; + const parentNoteId = getRandomNoteId(); + const prefix = Math.random() > 0.8 ? "prefix" : null; - // we'll create clones for 4% of notes - for (let i = 0; i < (noteCount / 25); i++) { - const noteIdToClone = getRandomNoteId(); - const parentNoteId = getRandomNoteId(); - const prefix = Math.random() > 0.8 ? "prefix" : null; + const result = await cloningService.cloneNoteToParent(noteIdToClone, parentNoteId, prefix); - const result = await cloningService.cloneNoteToParent(noteIdToClone, parentNoteId, prefix); + console.log(`Cloning ${i}:`, result.success ? "succeeded" : "FAILED"); + } - console.log(`Cloning ${i}:`, result.success ? "succeeded" : "FAILED"); - } - - for (let i = 0; i < noteCount; i++) { + // does not have to be for the current note await attributeService.createAttribute({ noteId: getRandomNoteId(), type: 'label', @@ -66,10 +76,6 @@ async function start() { 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', @@ -78,7 +84,9 @@ async function start() { isInheritable: Math.random() > 0.1 // 10% are inheritable }); - console.log(`Creating relation ${i}`); + noteRevisionService.createNoteRevision(await repository.getNote(getRandomNoteId())); + + notes.push(note.noteId); } process.exit(0);