mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
[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:
@@ -282,11 +282,11 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
if (options.SearchQueryTuningEnabled)
|
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
|
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
|
// remove history items in they are in the list as non-history items
|
||||||
|
|||||||
@@ -187,5 +187,20 @@ namespace Wox.Plugin
|
|||||||
/// Gets plugin ID that generated this result
|
/// Gets plugin ID that generated this result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PluginID { get; internal set; }
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user