pi-hole / web

Pi-hole Dashboard for stats and more
https://pi-hole.net
Other
2.05k stars 559 forks source link

api_db.php?topClients should behave like api.php?topClients and return configurable number of records #1736

Open zimjjan opened 3 years ago

zimjjan commented 3 years ago

Versions

Platform

Expected behavior

Calling api_db.php?topClients=25 should return 25 records.

Actual behavior / bug

Always returns 10.

(In addition, aggregation is done in php, so there is not even a performance advantage in doing so.)

Steps to reproduce

Call API as mentioned above.

yubiuser commented 3 years ago

api_db.php uses the long-term database instead of the data directly from memory (as api.php) does. The former has a hard-coded limit of ten clients https://github.com/pi-hole/AdminLTE/blob/1521dfe3f46eb7bfd87a0644a1fadcf5bfd0f7f9/api_db.php#L182

You could get the information via SQL directly from the database. In v6.0 Pi-hole will get a completely new API, which might allow (@DL6ER ?) querying any number of top clients from the long-term database as well.

https://deploy-preview-338--pihole-docs.netlify.app/api/

DL6ER commented 3 years ago

A quick look at the code says: Yes, this is already supported in the v6.0 code:

https://github.com/pi-hole/FTL/blob/01bb3bce23fa6009c1a7fd5130546f7ff14fed02/src/api/stats_database.c#L171-L173

Please note that the linked documentation is still lacking somewhat behind the development and will be soon replaced by a documentation inbuilt into FTL (this has the benefit of being always correct for the version you have at hand).

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.