mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	
		
			
	
	
		
			26 lines
		
	
	
		
			766 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			766 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|   | const notes = await api.runOnBackend(() => { | ||
|  |     return api.sql.getRows(`
 | ||
|  |         SELECT | ||
|  |             notes.noteId, | ||
|  |             COUNT(attributes.attributeId) AS count | ||
|  |         FROM notes | ||
|  |         JOIN attributes ON attributes.value = notes.noteId | ||
|  |         WHERE notes.isDeleted = 0 | ||
|  |           AND attributes.isDeleted = 0 | ||
|  |           AND attributes.type = 'relation' | ||
|  |         GROUP BY notes.noteId | ||
|  |         ORDER BY count DESC | ||
|  |         LIMIT 100`);
 | ||
|  | }); | ||
|  | 
 | ||
|  | const $statsTable = api.$container.find('.stats-table'); | ||
|  | 
 | ||
|  | for (const note of notes) {      | ||
|  |     $statsTable.append( | ||
|  |         $("<tr>") | ||
|  |             .append( | ||
|  |                 $("<td>").append(await api.createLink(note.noteId, {showNotePath: true})) | ||
|  |             )  | ||
|  |             .append($("<td nowrap>").text(note.count)) | ||
|  |     ); | ||
|  | } |