[PTRun] Allow preventing usage based ordering results (#37491)

* Allow preventing selected result data retrieval

* Updated implementation to calculate sort order on result and update property name to better reflect purpose

* Update Result.cs sort order method name

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Align with the name GetSortOrderScore

---------

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
This commit is contained in:
Corey Hayward
2025-04-25 05:27:54 +01:00
committed by GitHub
parent 26fe36ab8d
commit 7dc2a05c45
2 changed files with 17 additions and 2 deletions

View File

@@ -282,11 +282,11 @@ namespace PowerLauncher.ViewModel
if (options.SearchQueryTuningEnabled)
{
sorted = Results.OrderByDescending(x => (x.Result.Metadata.WeightBoost + x.Result.Score + (x.Result.SelectedCount * options.SearchClickedItemWeight))).ToList();
sorted = Results.OrderByDescending(x => x.Result.GetSortOrderScore(options.SearchClickedItemWeight)).ToList();
}
else
{
sorted = Results.OrderByDescending(x => (x.Result.Metadata.WeightBoost + x.Result.Score + (x.Result.SelectedCount * 5))).ToList();
sorted = Results.OrderByDescending(x => x.Result.GetSortOrderScore(5)).ToList();
}
// remove history items in they are in the list as non-history items

View File

@@ -187,5 +187,20 @@ namespace Wox.Plugin
/// Gets plugin ID that generated this result
/// </summary>
public string PluginID { get; internal set; }
/// <summary>
/// Gets or sets a value indicating whether usage based sorting should be applied to this result.
/// </summary>
public bool DisableUsageBasedScoring { get; set; }
public int GetSortOrderScore(int selectedItemMultiplier)
{
if (DisableUsageBasedScoring)
{
return Metadata.WeightBoost + Score;
}
return Metadata.WeightBoost + Score + (SelectedCount * selectedItemMultiplier);
}
}
}