Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PTRun] Allow preventing usage based ordering results #37491

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated implementation to calculate sort order on result and update p…
…roperty name to better reflect purpose
  • Loading branch information
CoreyHayward committed Feb 17, 2025
commit 2ce895a0832c84deecf1826cdeb83aa384bbda3a
Original file line number Diff line number Diff line change
@@ -282,11 +282,11 @@ public void Sort(MainViewModel.QueryTuningOptions options)

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.GetSortOrder(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.GetSortOrder(5)).ToList();
}

// remove history items in they are in the list as non-history items
15 changes: 12 additions & 3 deletions src/modules/launcher/Wox.Plugin/Result.cs
Original file line number Diff line number Diff line change
@@ -189,9 +189,18 @@ public override string ToString()
public string PluginID { get; internal set; }

/// <summary>
/// Gets or sets a value indicating whether the selected data should be applied to this result.
/// Gets or sets a value indicating whether usage based sorting should be applied to this result.
/// </summary>
/// <remarks>Enabling this option will affect the sort ordering of this result</remarks>
public bool DisableSelectedDataRetrieval { get; set; }
public bool DisableUsageBasedScoring { get; set; }

public int GetSortOrder(int selectedItemMultiplier)
{
if (DisableUsageBasedScoring)
{
return Metadata.WeightBoost + Score;
}

return Metadata.WeightBoost + Score + (SelectedCount * selectedItemMultiplier);
}
}
}
2 changes: 1 addition & 1 deletion src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ public UserSelectedRecordItem GetSelectedData(Result result)
{
ArgumentNullException.ThrowIfNull(result);

if (result != null && !result.DisableSelectedDataRetrieval && Records.TryGetValue(result.ToString(), out var value))
if (result != null && Records.TryGetValue(result.ToString(), out var value))
{
return value;
}