mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PTRun]Settings for result order tuning (#18978)
* Change to allow new settings for results tuning. * Change to allow new settings for results tuning. * Added WeightBoost * Fixed null-ref crash in QueryResults * Change based on stefansjfw review. Remove PowerLauncher_PluginWeightBoost.Content * Fixed another of my dumb null-refs... * Updated some text * Moved global sort order and set enable/disabled as needed. * Fixed enabled-state of "Global sort order score modifier" setting.
This commit is contained in:
@@ -11,8 +11,15 @@ namespace PowerLauncher.Storage
|
||||
{
|
||||
public class UserSelectedRecord
|
||||
{
|
||||
public class UserSelectedRecordItem
|
||||
{
|
||||
public int SelectedCount { get; set; }
|
||||
|
||||
public DateTime LastSelected { get; set; }
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
public Dictionary<string, int> Records { get; private set; } = new Dictionary<string, int>();
|
||||
public Dictionary<string, UserSelectedRecordItem> Records { get; private set; } = new Dictionary<string, UserSelectedRecordItem>();
|
||||
|
||||
public void Add(Result result)
|
||||
{
|
||||
@@ -22,29 +29,30 @@ namespace PowerLauncher.Storage
|
||||
}
|
||||
|
||||
var key = result.ToString();
|
||||
if (Records.TryGetValue(key, out int value))
|
||||
if (Records.TryGetValue(key, out var value))
|
||||
{
|
||||
Records[key] = value + 1;
|
||||
Records[key].SelectedCount = Records[key].SelectedCount + 1;
|
||||
Records[key].LastSelected = DateTime.UtcNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
Records.Add(key, 1);
|
||||
Records.Add(key, new UserSelectedRecordItem { SelectedCount = 1, LastSelected = DateTime.UtcNow });
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSelectedCount(Result result)
|
||||
public UserSelectedRecordItem GetSelectedData(Result result)
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(result));
|
||||
}
|
||||
|
||||
if (result != null && Records.TryGetValue(result.ToString(), out int value))
|
||||
if (result != null && Records.TryGetValue(result.ToString(), out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return new UserSelectedRecordItem { SelectedCount = 0, LastSelected = DateTime.MinValue };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user