-
-
Save Sachin-Kottarathodi/c3a0647d3fdd0fe8a76425e0594e11c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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