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:
DL6ER
2024-09-02 06:49:53 +02:00
parent 9afc12ebc4
commit 0fa865a29e
4 changed files with 12 additions and 0 deletions
+4
View File
@@ -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:
+1
View File
@@ -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);
+5
View File
@@ -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;
}
+2
View File
@@ -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