elif mode == "error_code":
database.cursor.execute("SELECT last_status_code, COUNT(domain) AS score FROM instances WHERE last_status_code IS NOT NULL AND last_status_code != '200' GROUP BY last_status_code ORDER BY score DESC LIMIT ?", [amount])
elif mode == "avg_peers":
- database.cursor.execute("SELECT software, AVG(total_peers) AS sum FROM instances WHERE software IS NOT NULL GROUP BY software HAVING sum>0 ORDER BY sum DESC LIMIT ?", [amount])
+ database.cursor.execute("SELECT software, AVG(total_peers) AS average FROM instances WHERE software IS NOT NULL GROUP BY software HAVING average>0 ORDER BY average DESC LIMIT ?", [amount])
elif mode == "obsfucator":
- database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obsfucation IS NOT NULL GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount])
+ database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obsfucation = 1 GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount])
else:
raise HTTPException(status_code=400, detail="No filter specified")
logger.debug(f"blocker='{blocker}'")
instances.set_last_blocked(blocker)
+ instances.set_has_obsfucation(blocker, False)
if software == "pleroma":
logger.info("blocker='%s',software='%s'", blocker, software)
logger.debug("EXIT!")
def set_has_obsfucation(domain: str, status: bool):
- logger.debug("domain(%d)='%s',status='%s' - CALLED!", len(domain), domain)
+ logger.debug("domain(%d)='%s',status='%s' - CALLED!", len(domain), domain, status)
domain_helper.raise_on(domain)
if not isinstance(status, bool):
logger.debug(f"domain='{domain}' de-obscured to '{row[0]}'")
domain = row[0]
+ else:
+ logger.debug("blocker='%s' has NO obsfucation on their block list", blocker)
+ instances.set_has_obsfucation(blocker, False)
+
+ if instances.has_pending(blocker):
+ logger.debug("Invoking instances.update_data(%s) ...", blocker)
+ instances.update_data(blocker)
if not is_domain_wanted(domain):
logger.debug("domain='%s' is not wanted - SKIPPED!", domain)