mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[PT Run] Split indexer plugin's queries into a fast and slow query (#5748)
* Added regex code * Added regex based method to remove all LIKE queries * Made regex readonly * Added plugin interface and code to execute slower plugins after the fast plugins * Added scoring for indexer and added statement to remove old indexer results * Refactored from master and added thread sleep for debugging * Removed lock from indexer plugin and added checks to avoid exceptions * Remove debug statement * Removed selected index update and fixed tests not building * Added tests * Removed scoring * Removed lock * Resolve merge conflicts * Moved dispatcher code to function and add parallel foreach loop * Removed DelayedExec metadata and modified QueryForPlugin to run only delayed exec plugins when bool param is true * Removed metadata from plugin.json
This commit is contained in:
@@ -152,7 +152,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Result> QueryForPlugin(PluginPair pair, Query query)
|
||||
public static List<Result> QueryForPlugin(PluginPair pair, Query query, bool delayedExecution = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -160,8 +160,19 @@ namespace Wox.Core.Plugin
|
||||
var metadata = pair.Metadata;
|
||||
var milliseconds = Stopwatch.Debug($"|PluginManager.QueryForPlugin|Cost for {metadata.Name}", () =>
|
||||
{
|
||||
results = pair.Plugin.Query(query) ?? new List<Result>();
|
||||
UpdatePluginMetadata(results, metadata, query);
|
||||
if (delayedExecution && (pair.Plugin is IDelayedExecutionPlugin))
|
||||
{
|
||||
results = ((IDelayedExecutionPlugin)pair.Plugin).Query(query, delayedExecution) ?? new List<Result>();
|
||||
}
|
||||
else if (!delayedExecution)
|
||||
{
|
||||
results = pair.Plugin.Query(query) ?? new List<Result>();
|
||||
}
|
||||
|
||||
if (results != null)
|
||||
{
|
||||
UpdatePluginMetadata(results, metadata, query);
|
||||
}
|
||||
});
|
||||
metadata.QueryCount += 1;
|
||||
metadata.AvgQueryTime = metadata.QueryCount == 1 ? milliseconds : (metadata.AvgQueryTime + milliseconds) / 2;
|
||||
|
||||
Reference in New Issue
Block a user