mirror of
https://github.com/pi-hole/pi-hole.git
synced 2026-04-02 00:27:56 +01:00
add antigravity index in the same way we already build the gravity index
Signed-off-by: Dominik <dl6er@dl6er.de>
This commit is contained in:
17
gravity.sh
17
gravity.sh
@@ -86,16 +86,17 @@ generate_gravity_database() {
|
||||
|
||||
# Build gravity tree
|
||||
gravity_build_tree() {
|
||||
local table="$1"
|
||||
local str
|
||||
str="Building tree"
|
||||
str="Building ${table} tree"
|
||||
echo -ne " ${INFO} ${str}..."
|
||||
|
||||
# The index is intentionally not UNIQUE as poor quality adlists may contain domains more than once
|
||||
output=$({ pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "CREATE INDEX idx_gravity ON gravity (domain, adlist_id);"; } 2>&1)
|
||||
output=$({ pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "CREATE INDEX idx_${table} ON ${table} (domain, adlist_id);"; } 2>&1)
|
||||
status="$?"
|
||||
|
||||
if [[ "${status}" -ne 0 ]]; then
|
||||
echo -e "\\n ${CROSS} Unable to build gravity tree in ${gravityTEMPfile}\\n ${output}"
|
||||
echo -e "\\n ${CROSS} Unable to build ${table} tree in ${gravityTEMPfile}\\n ${output}"
|
||||
echo -e " ${INFO} If you have a large amount of domains, make sure your Pi-hole has enough RAM available\\n"
|
||||
return 1
|
||||
fi
|
||||
@@ -844,11 +845,11 @@ gravity_Table_Count() {
|
||||
local str="${2}"
|
||||
local num
|
||||
num="$(pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "SELECT COUNT(*) FROM ${table};")"
|
||||
if [[ "${table}" == "gravity" ]]; then
|
||||
if [[ "${table}" == "gravity" || "${table}" == "antigravity" ]]; then
|
||||
local unique
|
||||
unique="$(pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "SELECT COUNT(*) FROM (SELECT DISTINCT domain FROM ${table});")"
|
||||
echo -e " ${INFO} Number of ${str}: ${num} (${COL_BOLD}${unique} unique domains${COL_NC})"
|
||||
pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "INSERT OR REPLACE INTO info (property,value) VALUES ('gravity_count',${unique});"
|
||||
pihole-FTL sqlite3 -ni "${gravityTEMPfile}" "INSERT OR REPLACE INTO info (property,value) VALUES ('${table}_count',${unique});"
|
||||
else
|
||||
echo -e " ${INFO} Number of ${str}: ${num}"
|
||||
fi
|
||||
@@ -858,11 +859,14 @@ gravity_Table_Count() {
|
||||
gravity_ShowCount() {
|
||||
# Here we use the table "gravity" instead of the view "vw_gravity" for speed.
|
||||
# It's safe to replace it here, because right after a gravity run both will show the exactly same number of domains.
|
||||
echo ""
|
||||
gravity_Table_Count "gravity" "gravity domains"
|
||||
gravity_Table_Count "antigravity" "antigravity domains"
|
||||
gravity_Table_Count "domainlist WHERE type = 1 AND enabled = 1" "exact denied domains"
|
||||
gravity_Table_Count "domainlist WHERE type = 3 AND enabled = 1" "regex denied filters"
|
||||
gravity_Table_Count "domainlist WHERE type = 0 AND enabled = 1" "exact allowed domains"
|
||||
gravity_Table_Count "domainlist WHERE type = 2 AND enabled = 1" "regex allowed filters"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Trap Ctrl-C
|
||||
@@ -1149,7 +1153,8 @@ update_gravity_timestamp
|
||||
fix_owner_permissions "${gravityTEMPfile}"
|
||||
|
||||
# Build the tree
|
||||
timeit gravity_build_tree
|
||||
timeit gravity_build_tree gravity
|
||||
timeit gravity_build_tree antigravity
|
||||
|
||||
# Compute numbers to be displayed (do this after building the tree to get the
|
||||
# numbers quickly from the tree instead of having to scan the whole database)
|
||||
|
||||
Reference in New Issue
Block a user