fix(sync): replace cryptic sigil counters with readable output
Problem: sync summaries used unexplained sigils (`+/-/~` and `!`) that conveyed no meaning, mixed symbol and prose formats across operations, and `gcal push` silently swallowed failures with no aggregate counter. Solution: replace all summary `log.info` calls with a shared `fmt_counts` helper that formats `N label` pairs separated by ` | `, suppresses zero counts, and falls back to "nothing to do". Add a `failed` counter to `gcal.push` to surface errors previously only emitted as individual warnings.
This commit is contained in:
parent
991ac5b467
commit
b2efe168fe
2 changed files with 72 additions and 21 deletions
|
|
@ -195,6 +195,21 @@ local function unlink_remote(task, now_ts)
|
|||
task.modified = now_ts
|
||||
end
|
||||
|
||||
---@param parts {[1]: integer, [2]: string}[]
|
||||
---@return string
|
||||
local function fmt_counts(parts)
|
||||
local items = {}
|
||||
for _, p in ipairs(parts) do
|
||||
if p[1] > 0 then
|
||||
table.insert(items, p[1] .. ' ' .. p[2])
|
||||
end
|
||||
end
|
||||
if #items == 0 then
|
||||
return 'nothing to do'
|
||||
end
|
||||
return table.concat(items, ' | ')
|
||||
end
|
||||
|
||||
---@param task pending.Task
|
||||
---@return table
|
||||
local function task_to_gtask(task)
|
||||
|
|
@ -451,7 +466,13 @@ function M.push()
|
|||
buffer.render(buffer.bufnr())
|
||||
end
|
||||
log.info(
|
||||
string.format('Google Tasks pushed — +%d ~%d -%d !%d', created, updated, deleted, failed)
|
||||
'gtasks push: '
|
||||
.. fmt_counts({
|
||||
{ created, 'added' },
|
||||
{ updated, 'updated' },
|
||||
{ deleted, 'deleted' },
|
||||
{ failed, 'failed' },
|
||||
})
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
|
@ -475,13 +496,13 @@ function M.pull()
|
|||
buffer.render(buffer.bufnr())
|
||||
end
|
||||
log.info(
|
||||
string.format(
|
||||
'Google Tasks pulled — +%d ~%d !%d, unlinked: %d',
|
||||
created,
|
||||
updated,
|
||||
failed,
|
||||
unlinked
|
||||
)
|
||||
'gtasks pull: '
|
||||
.. fmt_counts({
|
||||
{ created, 'added' },
|
||||
{ updated, 'updated' },
|
||||
{ unlinked, 'unlinked' },
|
||||
{ failed, 'failed' },
|
||||
})
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
|
@ -507,17 +528,20 @@ function M.sync()
|
|||
buffer.render(buffer.bufnr())
|
||||
end
|
||||
log.info(
|
||||
string.format(
|
||||
'Google Tasks synced — push: +%d ~%d -%d !%d, pull: +%d ~%d !%d, unlinked: %d',
|
||||
pushed_create,
|
||||
pushed_update,
|
||||
pushed_delete,
|
||||
pushed_failed,
|
||||
pulled_create,
|
||||
pulled_update,
|
||||
pulled_failed,
|
||||
unlinked
|
||||
)
|
||||
'gtasks sync — push: '
|
||||
.. fmt_counts({
|
||||
{ pushed_create, 'added' },
|
||||
{ pushed_update, 'updated' },
|
||||
{ pushed_delete, 'deleted' },
|
||||
{ pushed_failed, 'failed' },
|
||||
})
|
||||
.. ' pull: '
|
||||
.. fmt_counts({
|
||||
{ pulled_create, 'added' },
|
||||
{ pulled_update, 'updated' },
|
||||
{ unlinked, 'unlinked' },
|
||||
{ pulled_failed, 'failed' },
|
||||
})
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue