mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Add GET /api/stats/summary -> .gravity.last_update timestamp exposing the last gravity update via the API
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -560,6 +560,10 @@ components:
|
||||
type: integer
|
||||
description: Number of domain on your Pi-hole's gravity list
|
||||
example: 104756
|
||||
last_update:
|
||||
type: integer
|
||||
description: Unix timestamp of last gravity update (may be `0` if unknown)
|
||||
example: 1725194639
|
||||
upstreams:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -165,6 +165,7 @@ int api_stats_summary(struct ftl_conn *api)
|
||||
|
||||
cJSON *gravity = JSON_NEW_OBJECT();
|
||||
JSON_ADD_NUMBER_TO_OBJECT(gravity, "domains_being_blocked", num_gravity);
|
||||
JSON_ADD_NUMBER_TO_OBJECT(gravity, "last_update", gravity_last_updated());
|
||||
|
||||
cJSON *json = JSON_NEW_OBJECT();
|
||||
JSON_ADD_ITEM_TO_OBJECT(json, "queries", queries);
|
||||
|
||||
@@ -2796,3 +2796,8 @@ bool gravity_updated(void)
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
time_t __attribute__((pure)) gravity_last_updated(void)
|
||||
{
|
||||
return last_updated > 0 ? (time_t)last_updated : 0;
|
||||
}
|
||||
|
||||
@@ -70,4 +70,6 @@ bool gravityDB_delFromTable(const enum gravity_list_type listtype, const cJSON*
|
||||
bool gravityDB_edit_groups(const enum gravity_list_type listtype, cJSON *groups,
|
||||
const tablerow *row, const char **message);
|
||||
|
||||
time_t gravity_last_updated(void) __attribute__((pure));
|
||||
|
||||
#endif //GRAVITY_H
|
||||
|
||||
Reference in New Issue
Block a user