1- import type { TasksFile } from '../Scripting/TasksFile' ;
1+ import { GlobalFilter } from '../Config/GlobalFilter' ;
2+ import { GlobalQuery } from '../Config/GlobalQuery' ;
23import type { IQuery } from '../IQuery' ;
34import { State } from '../Obsidian/Cache' ;
4- import { Task } from '../Task/Task' ;
5- import type { QueryResult } from '../Query/QueryResult' ;
6- import type { TaskGroups } from '../Query/Group/TaskGroups' ;
7- import type { ListItem } from '../Task/ListItem' ;
85import type { GroupDisplayHeading } from '../Query/Group/GroupDisplayHeading' ;
9- import { PerformanceTracker } from '../lib/PerformanceTracker ' ;
6+ import type { TaskGroups } from '../Query/Group/TaskGroups ' ;
107import { explainResults } from '../Query/QueryRendererHelper' ;
11- import { GlobalFilter } from '../Config/GlobalFilter' ;
12- import { GlobalQuery } from '../Config/GlobalQuery' ;
8+ import type { QueryResult } from '../Query/QueryResult' ;
9+ import type { TasksFile } from '../Scripting/TasksFile' ;
10+ import type { ListItem } from '../Task/ListItem' ;
11+ import { Task } from '../Task/Task' ;
1312
1413/**
1514 * Because properties in QueryResultsRenderer may be modified during the lifetime of this class,
@@ -34,7 +33,7 @@ export abstract class QueryResultsRendererBase {
3433 return this . getters . tasksFile ( ) . path ;
3534 }
3635
37- public async renderQuery ( state : State | State . Warm , tasks : Task [ ] ) {
36+ public async renderQuery ( state : State , queryResult : QueryResult ) {
3837 this . beginRender ( ) ;
3938
4039 // Don't log anything here, for any state, as it generates huge amounts of
@@ -43,8 +42,7 @@ export abstract class QueryResultsRendererBase {
4342 const query = this . getters . query ( ) ;
4443 const error = query . error ;
4544 if ( state === State . Warm && error === undefined ) {
46- query . debug ( `[render] Render called: plugin state: ${ state } ; searching ${ tasks . length } tasks` ) ;
47- await this . renderQuerySearchResults ( tasks ) ;
45+ await this . renderQuerySearchResults ( queryResult ) ;
4846 } else if ( error ) {
4947 this . renderErrorMessage ( error ) ;
5048 } else {
@@ -59,8 +57,8 @@ export abstract class QueryResultsRendererBase {
5957 */
6058 protected abstract beginRender ( ) : void ;
6159
62- private async renderQuerySearchResults ( tasks : Task [ ] ) {
63- const queryResult = this . explainAndPerformSearch ( tasks ) ;
60+ private async renderQuerySearchResults ( queryResult : QueryResult ) {
61+ this . explainQuery ( ) ;
6462
6563 if ( queryResult . searchErrorMessage !== undefined ) {
6664 // There was an error in the search, for example due to a problem custom function.
@@ -71,10 +69,7 @@ export abstract class QueryResultsRendererBase {
7169 await this . renderSearchResults ( queryResult ) ;
7270 }
7371
74- private explainAndPerformSearch ( tasks : Task [ ] ) {
75- const measureSearch = new PerformanceTracker ( `Search: ${ this . getters . query ( ) . queryId } - ${ this . filePath } ` ) ;
76- measureSearch . start ( ) ;
77-
72+ private explainQuery ( ) {
7873 if ( this . getters . query ( ) . queryLayoutOptions . explainQuery ) {
7974 const explanation = explainResults (
8075 this . getters . source ( ) ,
@@ -84,17 +79,9 @@ export abstract class QueryResultsRendererBase {
8479 ) ;
8580 this . renderExplanation ( explanation ) ;
8681 }
87-
88- const queryResult = this . getters . query ( ) . applyQueryToTasks ( tasks ) ;
89-
90- measureSearch . finish ( ) ;
91- return queryResult ;
9282 }
9383
9484 private async renderSearchResults ( queryResult : QueryResult ) {
95- const measureRender = new PerformanceTracker ( `Render: ${ this . getters . query ( ) . queryId } - ${ this . filePath } ` ) ;
96- measureRender . start ( ) ;
97-
9885 this . renderSearchResultsHeader ( queryResult ) ;
9986
10087 await this . addAllTaskGroups ( queryResult . taskGroups ) ;
@@ -103,8 +90,6 @@ export abstract class QueryResultsRendererBase {
10390 this . getters . query ( ) . debug ( `[render] ${ totalTasksCount } tasks displayed` ) ;
10491
10592 this . renderSearchResultsFooter ( queryResult ) ;
106-
107- measureRender . finish ( ) ;
10893 }
10994
11095 protected abstract renderSearchResultsHeader ( queryResult : QueryResult ) : void ;
0 commit comments