feat: Opposite Activity Check (#9)

* add checking for total/active to filter additional instances

* added checking for low user count

* reverse calculation

* GT check
pull/13/head
Domenic Horner 2023-06-27 15:56:25 +08:00 committed by GitHub
parent c415e70c2c
commit fdb872f7cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -2,7 +2,7 @@ import requests
from loguru import logger from loguru import logger
from fediseer.consts import FEDISEER_VERSION from fediseer.consts import FEDISEER_VERSION
def retrieve_suspicious_instances(activity_suspicion = 20, active_suspicious = 500): def retrieve_suspicious_instances(activity_suspicion = 20, active_suspicious = 500, activity_suspicion_low = 400):
# GraphQL query # GraphQL query
query = ''' query = '''
{ {
@ -64,10 +64,17 @@ def retrieve_suspicious_instances(activity_suspicion = 20, active_suspicious = 5
continue continue
if local_activity == 0: if local_activity == 0:
local_activity= 1 local_activity= 1
# posts+comments could be much lower than total users
if node["total_users"] / local_activity > activity_suspicion: if node["total_users"] / local_activity > activity_suspicion:
is_bad = True is_bad = True
# print(node) # print(node)
# posts+comments could be much higher than total users
if local_activity / node["total_users"] > activity_suspicion_low:
is_bad = True
# print(node)
# check active users (monthly is a lot lower than total users) # check active users (monthly is a lot lower than total users)
local_active_monthly_users = node["active_users_monthly"] local_active_monthly_users = node["active_users_monthly"]
# Avoid division by 0 # Avoid division by 0