fix(views): pluralize unknown queue sort key warning

Problem: multiple unknown sort keys each triggered a separate warning.

Solution: collect unknown keys and emit a single warning with the
correct singular/plural label, joined by `, `.
This commit is contained in:
Barrett Ruth 2026-03-12 20:46:36 -04:00
parent 5ab0aa78a1
commit ddf1af79da
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -161,14 +161,19 @@ local function build_queue_comparator()
local log = require('pending.log')
local keys = config.get().view.queue.sort or { 'status', 'priority', 'due', 'order', 'id' }
local comparators = {}
local unknown = {}
for _, key in ipairs(keys) do
local cmp = sort_key_comparators[key]
if cmp then
table.insert(comparators, cmp)
else
log.warn('unknown queue sort key: ' .. key)
table.insert(unknown, key)
end
end
if #unknown > 0 then
local label = #unknown == 1 and 'unknown queue sort key: ' or 'unknown queue sort keys: '
log.warn(label .. table.concat(unknown, ', '))
end
return function(a, b)
for _, cmp in ipairs(comparators) do
local result = cmp(a, b)