1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-04 12:52:06 -04:00

launcher: fix frecency ranking in search results

fixes #1799
This commit is contained in:
bbedward
2026-02-22 22:34:26 -05:00
parent 85b00d3c76
commit 6ee419bc52
3 changed files with 9 additions and 14 deletions

View File

@@ -713,8 +713,6 @@ Item {
var apps = searchApps(searchQuery);
for (var i = 0; i < apps.length; i++) {
if (searchQuery)
apps[i]._preScored = 11000 - i;
allItems.push(apps[i]);
}
@@ -722,14 +720,11 @@ Item {
if (searchQuery && searchQuery.length >= 2) {
_pluginPhasePending = true;
_phase1Items = allItems.slice();
_pluginPhaseForceFirst = shouldResetSelection;
pluginPhaseTimer.restart();
if (allItems.length === 0) {
_pluginPhaseForceFirst = shouldResetSelection;
isSearching = true;
searchCompleted();
return;
}
_pluginPhaseForceFirst = false;
isSearching = true;
searchCompleted();
return;
} else if (!searchQuery) {
var emptyTriggerOrdered = getEmptyTriggerPluginsOrdered();
for (var i = 0; i < emptyTriggerOrdered.length; i++) {

View File

@@ -3,7 +3,7 @@
const Weights = {
exactMatch: 10000,
prefixMatch: 5000,
wordBoundary: 1000,
wordBoundary: 3000,
substring: 500,
fuzzy: 100,
frecency: 2000,
@@ -99,8 +99,8 @@ function getTimeBucketWeight(daysSinceUsed) {
function calculateTextScore(name, query) {
if (name === query) return Weights.exactMatch
if (name.startsWith(query)) return Weights.prefixMatch
if (name.includes(query)) return Weights.substring
if (hasWordBoundaryMatch(name, query)) return Weights.wordBoundary
if (name.includes(query)) return Weights.substring
if (query.length >= 3) {
var fs = fuzzyScore(name, query)
@@ -140,7 +140,7 @@ function score(item, query, frecencyData) {
if (textScore === 0) return 0
var usageBonus = frecencyData ? Math.min(frecencyData.usageCount * 10, Weights.frecency) : 0
var usageBonus = frecencyData ? Math.min(frecencyData.usageCount * 50, Weights.frecency) : 0
return textScore + usageBonus + typeBonus
}

View File

@@ -494,7 +494,7 @@ Singleton {
textScore = 5000;
matchType = "prefix";
} else if (wordBoundaryMatch(name, queryLower)) {
textScore = 1000;
textScore = 3000;
matchType = "word_boundary";
} else if (name.includes(queryLower)) {
textScore = 500;
@@ -551,7 +551,7 @@ Singleton {
}
for (const result of results) {
const frecencyBonus = result.frecency > 0 ? Math.min(result.frecency / 10, 2000) : 0;
const frecencyBonus = result.frecency > 0 ? Math.min(result.frecency, 2000) : 0;
const recencyBonus = result.daysSinceUsed < 1 ? 1500 : result.daysSinceUsed < 7 ? 1000 : result.daysSinceUsed < 30 ? 500 : 0;
const finalScore = result.textScore + frecencyBonus + recencyBonus;