mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
* refactor: simplify logic to load web_devicons * refactor: make register() asynchronous * fix: load lazily modules outside this plugin * refactor: simplify logic to wait initialization * refactor: use uv.hrtime() instead of os.clock() * fix: avoid errors in calling plenary.log in async * test: store elapsed time to check in tests * test: fix module names This becomes a problem only in Ubuntu because macOS and Windows does not care cases in filenames. * test: fix types and unused modules * style: fix by stylua * refactor: make recency / entry_maker loaded lazily
24 lines
473 B
Lua
24 lines
473 B
Lua
local config = require "frecency.config"
|
|
|
|
---@class FrecencyRecency
|
|
local M = {}
|
|
|
|
---@param count integer
|
|
---@param ages number[]
|
|
---@return number
|
|
function M.calculate(count, ages)
|
|
local score = 0
|
|
for _, age in ipairs(ages) do
|
|
for _, rank in ipairs(config.recency_values) do
|
|
if age <= rank.age then
|
|
score = score + rank.value
|
|
goto continue
|
|
end
|
|
end
|
|
::continue::
|
|
end
|
|
return count * score / config.max_timestamps
|
|
end
|
|
|
|
return M
|