mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	generate document now creates note revisions as well
This commit is contained in:
		
							parent
							
								
									3b690f5456
								
							
						
					
					
						commit
						9cb8bc5dd8
					
				| @ -57,7 +57,6 @@ | |||||||
|     <index id="24" parent="6" name="sqlite_autoindex_api_tokens_1"> |     <index id="24" parent="6" name="sqlite_autoindex_api_tokens_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>apiTokenId</ColNames> |       <ColNames>apiTokenId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <key id="25" parent="6"> |     <key id="25" parent="6"> | ||||||
| @ -126,21 +125,17 @@ | |||||||
|     <index id="37" parent="7" name="sqlite_autoindex_attributes_1"> |     <index id="37" parent="7" name="sqlite_autoindex_attributes_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>attributeId</ColNames> |       <ColNames>attributeId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <index id="38" parent="7" name="IDX_attributes_noteId_index"> |     <index id="38" parent="7" name="IDX_attributes_noteId_index"> | ||||||
|       <ColNames>noteId</ColNames> |       <ColNames>noteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="39" parent="7" name="IDX_attributes_name_value"> |     <index id="39" parent="7" name="IDX_attributes_name_value"> | ||||||
|       <ColNames>name |       <ColNames>name | ||||||
| value</ColNames> | value</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="40" parent="7" name="IDX_attributes_value_index"> |     <index id="40" parent="7" name="IDX_attributes_value_index"> | ||||||
|       <ColNames>value</ColNames> |       <ColNames>value</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <key id="41" parent="7"> |     <key id="41" parent="7"> | ||||||
|       <ColNames>attributeId</ColNames> |       <ColNames>attributeId</ColNames> | ||||||
| @ -202,17 +197,14 @@ value</ColNames> | |||||||
|     <index id="52" parent="8" name="sqlite_autoindex_branches_1"> |     <index id="52" parent="8" name="sqlite_autoindex_branches_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>branchId</ColNames> |       <ColNames>branchId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <index id="53" parent="8" name="IDX_branches_noteId_parentNoteId"> |     <index id="53" parent="8" name="IDX_branches_noteId_parentNoteId"> | ||||||
|       <ColNames>noteId |       <ColNames>noteId | ||||||
| parentNoteId</ColNames> | parentNoteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="54" parent="8" name="IDX_branches_parentNoteId"> |     <index id="54" parent="8" name="IDX_branches_parentNoteId"> | ||||||
|       <ColNames>parentNoteId</ColNames> |       <ColNames>parentNoteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <key id="55" parent="8"> |     <key id="55" parent="8"> | ||||||
|       <ColNames>branchId</ColNames> |       <ColNames>branchId</ColNames> | ||||||
| @ -243,7 +235,6 @@ parentNoteId</ColNames> | |||||||
|     <index id="60" parent="9" name="sqlite_autoindex_note_contents_1"> |     <index id="60" parent="9" name="sqlite_autoindex_note_contents_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>noteId</ColNames> |       <ColNames>noteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <key id="61" parent="9"> |     <key id="61" parent="9"> | ||||||
| @ -274,7 +265,6 @@ parentNoteId</ColNames> | |||||||
|     <index id="66" parent="10" name="sqlite_autoindex_note_revision_contents_1"> |     <index id="66" parent="10" name="sqlite_autoindex_note_revision_contents_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>noteRevisionId</ColNames> |       <ColNames>noteRevisionId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <key id="67" parent="10"> |     <key id="67" parent="10"> | ||||||
| @ -359,28 +349,22 @@ parentNoteId</ColNames> | |||||||
|     <index id="82" parent="11" name="sqlite_autoindex_note_revisions_1"> |     <index id="82" parent="11" name="sqlite_autoindex_note_revisions_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>noteRevisionId</ColNames> |       <ColNames>noteRevisionId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <index id="83" parent="11" name="IDX_note_revisions_noteId"> |     <index id="83" parent="11" name="IDX_note_revisions_noteId"> | ||||||
|       <ColNames>noteId</ColNames> |       <ColNames>noteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="84" parent="11" name="IDX_note_revisions_utcDateLastEdited"> |     <index id="84" parent="11" name="IDX_note_revisions_utcDateLastEdited"> | ||||||
|       <ColNames>utcDateLastEdited</ColNames> |       <ColNames>utcDateLastEdited</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="85" parent="11" name="IDX_note_revisions_utcDateCreated"> |     <index id="85" parent="11" name="IDX_note_revisions_utcDateCreated"> | ||||||
|       <ColNames>utcDateCreated</ColNames> |       <ColNames>utcDateCreated</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="86" parent="11" name="IDX_note_revisions_dateLastEdited"> |     <index id="86" parent="11" name="IDX_note_revisions_dateLastEdited"> | ||||||
|       <ColNames>dateLastEdited</ColNames> |       <ColNames>dateLastEdited</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="87" parent="11" name="IDX_note_revisions_dateCreated"> |     <index id="87" parent="11" name="IDX_note_revisions_dateCreated"> | ||||||
|       <ColNames>dateCreated</ColNames> |       <ColNames>dateCreated</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <key id="88" parent="11"> |     <key id="88" parent="11"> | ||||||
|       <ColNames>noteRevisionId</ColNames> |       <ColNames>noteRevisionId</ColNames> | ||||||
| @ -462,36 +446,28 @@ parentNoteId</ColNames> | |||||||
|     <index id="102" parent="12" name="sqlite_autoindex_notes_1"> |     <index id="102" parent="12" name="sqlite_autoindex_notes_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>noteId</ColNames> |       <ColNames>noteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <index id="103" parent="12" name="IDX_notes_title"> |     <index id="103" parent="12" name="IDX_notes_title"> | ||||||
|       <ColNames>title</ColNames> |       <ColNames>title</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="104" parent="12" name="IDX_notes_type"> |     <index id="104" parent="12" name="IDX_notes_type"> | ||||||
|       <ColNames>type</ColNames> |       <ColNames>type</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="105" parent="12" name="IDX_notes_isDeleted"> |     <index id="105" parent="12" name="IDX_notes_isDeleted"> | ||||||
|       <ColNames>isDeleted</ColNames> |       <ColNames>isDeleted</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="106" parent="12" name="IDX_notes_dateCreated"> |     <index id="106" parent="12" name="IDX_notes_dateCreated"> | ||||||
|       <ColNames>dateCreated</ColNames> |       <ColNames>dateCreated</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="107" parent="12" name="IDX_notes_dateModified"> |     <index id="107" parent="12" name="IDX_notes_dateModified"> | ||||||
|       <ColNames>dateModified</ColNames> |       <ColNames>dateModified</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="108" parent="12" name="IDX_notes_utcDateCreated"> |     <index id="108" parent="12" name="IDX_notes_utcDateCreated"> | ||||||
|       <ColNames>utcDateCreated</ColNames> |       <ColNames>utcDateCreated</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <index id="109" parent="12" name="IDX_notes_utcDateModified"> |     <index id="109" parent="12" name="IDX_notes_utcDateModified"> | ||||||
|       <ColNames>utcDateModified</ColNames> |       <ColNames>utcDateModified</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <key id="110" parent="12"> |     <key id="110" parent="12"> | ||||||
|       <ColNames>noteId</ColNames> |       <ColNames>noteId</ColNames> | ||||||
| @ -532,7 +508,6 @@ parentNoteId</ColNames> | |||||||
|     <index id="117" parent="13" name="sqlite_autoindex_options_1"> |     <index id="117" parent="13" name="sqlite_autoindex_options_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>name</ColNames> |       <ColNames>name</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <key id="118" parent="13"> |     <key id="118" parent="13"> | ||||||
| @ -568,7 +543,6 @@ parentNoteId</ColNames> | |||||||
|     <index id="124" parent="14" name="sqlite_autoindex_recent_notes_1"> |     <index id="124" parent="14" name="sqlite_autoindex_recent_notes_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>noteId</ColNames> |       <ColNames>noteId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <key id="125" parent="14"> |     <key id="125" parent="14"> | ||||||
| @ -589,12 +563,10 @@ parentNoteId</ColNames> | |||||||
|     <index id="128" parent="15" name="sqlite_autoindex_source_ids_1"> |     <index id="128" parent="15" name="sqlite_autoindex_source_ids_1"> | ||||||
|       <NameSurrogate>1</NameSurrogate> |       <NameSurrogate>1</NameSurrogate> | ||||||
|       <ColNames>sourceId</ColNames> |       <ColNames>sourceId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <index id="129" parent="15" name="IDX_source_ids_utcDateCreated"> |     <index id="129" parent="15" name="IDX_source_ids_utcDateCreated"> | ||||||
|       <ColNames>utcDateCreated</ColNames> |       <ColNames>utcDateCreated</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <key id="130" parent="15"> |     <key id="130" parent="15"> | ||||||
|       <ColNames>sourceId</ColNames> |       <ColNames>sourceId</ColNames> | ||||||
| @ -656,12 +628,10 @@ parentNoteId</ColNames> | |||||||
|     <index id="143" parent="18" name="IDX_sync_entityName_entityId"> |     <index id="143" parent="18" name="IDX_sync_entityName_entityId"> | ||||||
|       <ColNames>entityName |       <ColNames>entityName | ||||||
| entityId</ColNames> | entityId</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|       <Unique>1</Unique> |       <Unique>1</Unique> | ||||||
|     </index> |     </index> | ||||||
|     <index id="144" parent="18" name="IDX_sync_utcSyncDate"> |     <index id="144" parent="18" name="IDX_sync_utcSyncDate"> | ||||||
|       <ColNames>utcSyncDate</ColNames> |       <ColNames>utcSyncDate</ColNames> | ||||||
|       <ColumnCollations></ColumnCollations> |  | ||||||
|     </index> |     </index> | ||||||
|     <key id="145" parent="18"> |     <key id="145" parent="18"> | ||||||
|       <ColNames>id</ColNames> |       <ColNames>id</ColNames> | ||||||
|  | |||||||
| @ -9,6 +9,8 @@ const noteService = require('../services/notes'); | |||||||
| const attributeService = require('../services/attributes'); | 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 repository = require('../services/repository'); | ||||||
|  | const noteRevisionService = require('../services/note_revisions'); | ||||||
| const loremIpsum = require('lorem-ipsum').loremIpsum; | const loremIpsum = require('lorem-ipsum').loremIpsum; | ||||||
| 
 | 
 | ||||||
| const noteCount = parseInt(process.argv[2]); | const noteCount = parseInt(process.argv[2]); | ||||||
| @ -28,11 +30,23 @@ function getRandomNoteId() { | |||||||
| 
 | 
 | ||||||
| async function start() { | async function start() { | ||||||
|     for (let i = 0; i < noteCount; i++) { |     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 paragraphCount = Math.floor(Math.random() * Math.random() * 100); | ||||||
|         const content = loremIpsum({ count: paragraphCount, units: 'paragraphs', sentenceLowerBound: 1, sentenceUpperBound: 15, |         const content = loremIpsum({ | ||||||
|             paragraphLowerBound: 3, paragraphUpperBound: 10, format: 'html' }); |             count: paragraphCount, | ||||||
|  |             units: 'paragraphs', | ||||||
|  |             sentenceLowerBound: 1, | ||||||
|  |             sentenceUpperBound: 15, | ||||||
|  |             paragraphLowerBound: 3, | ||||||
|  |             paragraphUpperBound: 10, | ||||||
|  |             format: 'html' | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         const {note} = await noteService.createNewNote({ |         const {note} = await noteService.createNewNote({ | ||||||
|             parentNoteId: getRandomNoteId(), |             parentNoteId: getRandomNoteId(), | ||||||
| @ -43,21 +57,17 @@ async function start() { | |||||||
| 
 | 
 | ||||||
|         console.log(`Created note ${i}: ${title}`); |         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
 |             const result = await cloningService.cloneNoteToParent(noteIdToClone, parentNoteId, prefix); | ||||||
|     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); |             console.log(`Cloning ${i}:`, result.success ? "succeeded" : "FAILED"); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         console.log(`Cloning ${i}:`, result.success ? "succeeded" : "FAILED"); |         // does not have to be for the current note
 | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     for (let i = 0; i < noteCount; i++) { |  | ||||||
|         await attributeService.createAttribute({ |         await attributeService.createAttribute({ | ||||||
|             noteId: getRandomNoteId(), |             noteId: getRandomNoteId(), | ||||||
|             type: 'label', |             type: 'label', | ||||||
| @ -66,10 +76,6 @@ async function start() { | |||||||
|             isInheritable: Math.random() > 0.1 // 10% are inheritable
 |             isInheritable: Math.random() > 0.1 // 10% are inheritable
 | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         console.log(`Creating label ${i}`); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     for (let i = 0; i < noteCount; i++) { |  | ||||||
|         await attributeService.createAttribute({ |         await attributeService.createAttribute({ | ||||||
|             noteId: getRandomNoteId(), |             noteId: getRandomNoteId(), | ||||||
|             type: 'relation', |             type: 'relation', | ||||||
| @ -78,7 +84,9 @@ async function start() { | |||||||
|             isInheritable: Math.random() > 0.1 // 10% are inheritable
 |             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); |     process.exit(0); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam