mirror of
https://github.com/pi-hole/FTL.git
synced 2026-10-08 13:19:48 +01:00
The clients object was keyed by the address from `client_by_id` and
carried only the name, while history[].data was keyed by the raw
`query_storage.client` column, which holds the `client_by_id` id. The two
halves of the response could not be joined, unlike the in-memory
`/api/history/clients` that shares the client_history schema and reports
{name, total} per address.
The slot query also grouped by `(timestamp/:interval)*:interval`, which
is a real division since the timestamps are stored with a fractional
part, so nothing was grouped: the data object received one entry per
query, repeating the same key with a count of 1.
Join `client_by_id` in both statements and group by the address (an
address can have several ids, one per name it was seen with), add the
per-client total, and truncate the timestamp before the integer division
so the slots form.
Signed-off-by: 010011110 <duckenheim@posteo.de>