Save number of ABP-style entries in adlist table's new column abp_entries

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-06-15 09:35:45 +02:00
parent 0002399916
commit 07f1f7df44
6 changed files with 32 additions and 13 deletions
+5
View File
@@ -259,6 +259,11 @@ components:
type: integer
readOnly: true
example: 0
abp_entries:
description: Number of ABP entries on this list
type: integer
readOnly: true
example: 0
status:
description: List status
type: integer
+4
View File
@@ -133,6 +133,10 @@ components:
type: integer
description: Number of invalid domains in the adlist
example: 0
abp_entries:
type: integer
description: Number of ABP entries in the adlist
example: 0
status:
type: integer
description: Status of the adlist
+1
View File
@@ -68,6 +68,7 @@ static int search_table(struct ftl_conn *api,
JSON_ADD_NUMBER_TO_OBJECT(row, "date_updated", table.date_updated);
JSON_ADD_NUMBER_TO_OBJECT(row, "number", table.number);
JSON_ADD_NUMBER_TO_OBJECT(row, "invalid_domains", table.invalid_domains);
JSON_ADD_NUMBER_TO_OBJECT(row, "abp_entries", table.abp_entries);
JSON_ADD_NUMBER_TO_OBJECT(row, "status", table.status);
}
+1
View File
@@ -23,6 +23,7 @@ typedef struct {
int type_int;
int number;
int invalid_domains;
int abp_entries;
int status;
const char *name;
const char *domain;
+10 -3
View File
@@ -279,7 +279,7 @@ int gravity_parseList(const char *infile, const char *outfile, const char *adlis
}
// Update number of domains and update timestamp on this list
sql = "UPDATE adlist SET number = ?, invalid_domains = ?, date_updated = cast(strftime('%s', 'now') as int) WHERE id = ?;";
sql = "UPDATE adlist SET number = ?, invalid_domains = ?, abp_entries = ?, date_updated = cast(strftime('%s', 'now') as int) WHERE id = ?;";
if(sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK)
{
printf("%s %s Unable to prepare SQL statement to update adlist properties in database file %s\n",
@@ -289,7 +289,6 @@ int gravity_parseList(const char *infile, const char *outfile, const char *adlis
return EXIT_FAILURE;
}
// Update date
if(sqlite3_bind_int(stmt, 1, exact_domains + abp_domains) != SQLITE_OK)
{
printf("%s %s Unable to bind number of entries to SQL statement to update adlist properties in database file %s\n",
@@ -306,7 +305,15 @@ int gravity_parseList(const char *infile, const char *outfile, const char *adlis
sqlite3_close(db);
return EXIT_FAILURE;
}
if(sqlite3_bind_int(stmt, 3, adlistID) != SQLITE_OK)
if(sqlite3_bind_int(stmt, 3, abp_domains) != SQLITE_OK)
{
printf("%s %s Unable to bind number of ABP entries to SQL statement to update adlist properties in database file %s\n",
over, cross, outfile);
fclose(fpin);
sqlite3_close(db);
return EXIT_FAILURE;
}
if(sqlite3_bind_int(stmt, 4, adlistID) != SQLITE_OK)
{
printf("%s %s Unable to bind adlist ID to SQL statement to update adlist properties in database file %s\n",
over, cross, outfile);
+11 -10
View File
@@ -25,16 +25,17 @@ CREATE TABLE domainlist
CREATE TABLE adlist
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
address TEXT UNIQUE NOT NULL,
enabled BOOLEAN NOT NULL DEFAULT 1,
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
id INTEGER PRIMARY KEY AUTOINCREMENT,
address TEXT UNIQUE NOT NULL,
enabled BOOLEAN NOT NULL DEFAULT 1,
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s','now') as int)),
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s','now') as int)),
comment TEXT,
date_updated INTEGER,
number INTEGER NOT NULL DEFAULT 0,
invalid_domains INTEGER NOT NULL DEFAULT 0,
status INTEGER NOT NULL DEFAULT 0
date_updated INTEGER,
number INTEGER NOT NULL DEFAULT 0,
invalid_domains INTEGER NOT NULL DEFAULT 0,
status INTEGER NOT NULL DEFAULT 0,
abp_entries INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE adlist_by_group
@@ -214,7 +215,7 @@ INSERT INTO domainlist VALUES(16,3,'^regex-notMultiple.ftl$;querytype=!ANY,HTTPS
/* Other special domains */
INSERT INTO domainlist VALUES(17,1,'blacklisted-group-disabled.com',1,1559928803,1559928803,'Entry disabled by a group');
INSERT INTO adlist VALUES(1,'https://hosts-file.net/ad_servers.txt',1,1559928803,1559928803,'Migrated from /etc/pihole/adlists.list',1559928803,2000,2,1);
INSERT INTO adlist VALUES(1,'https://hosts-file.net/ad_servers.txt',1,1559928803,1559928803,'Migrated from /etc/pihole/adlists.list',1559928803,2000,2,1,0);
INSERT INTO gravity VALUES('allowed.ftl',1);
INSERT INTO gravity VALUES('gravity.ftl',1);