Skip to content

Instantly share code, notes, and snippets.

@Sachin-Kottarathodi
Last active October 10, 2021 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sachin-Kottarathodi/c3a0647d3fdd0fe8a76425e0594e11c5 to your computer and use it in GitHub Desktop.
Save Sachin-Kottarathodi/c3a0647d3fdd0fe8a76425e0594e11c5 to your computer and use it in GitHub Desktop.
def ip_fraud(self, data):
exists = RedisConn().bloom().cfExists(Constants.IP_CUCKOO_FILTER_NAME, data['ip'])
if exists:
data['fraud_type'] = Constants.IP_BLACKLIST
data['status'] = Constants.FRAUD
return exists
def click_spam(self, data):
is_click_spammed = False
count = RedisConn().redis().zcount(data.get('device_id'), data['ts'] - self.click_spam_window_in_sec, data['ts'])
if count >= self.click_spam_threshold:
is_click_spammed = True
data['fraud_type'] = Constants.CLICK_SPAM
data['status'] = Constants.FRAUD
return is_click_spammed
def publish(self, data):
RedisConn().redis().xadd(Constants.STREAM_NAME, data, id='*')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment