Detect which are the IPs and polls that are triggering our fraud activity notifications:
SELECT
user_ip,
poll_id,
COUNT(*) AS fraud_votes
FROM
events.fraudvote
WHERE| package main | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| func parseSplit(tags string, key string) string { | |
| for _, tag := range strings.Split(tags, ",") { | |
| parts := strings.Split(tag, ":") |
| import datetime | |
| from datalayer.metrics_api import metric_query, OK_STATUS | |
| from dd.utils.query import QuerySource, QuerySourceTypes | |
| t_from = datetime.datetime.strptime("2022-06-01 00:00:00", '%Y-%m-%d %H:%M:%S') | |
| t_to = datetime.datetime.strptime("2022-06-08 00:00:00", '%Y-%m-%d %H:%M:%S') | |
| def parse_agent_version_tag(agent_version_tag): | |
| agent_version = agent_version_tag[8:] # "version:" prefix | |
| parts = agent_version.split(".") |
Detect which are the IPs and polls that are triggering our fraud activity notifications:
SELECT
user_ip,
poll_id,
COUNT(*) AS fraud_votes
FROM
events.fraudvote
WHERE| userId | itemId | type | |
|---|---|---|---|
| 1 | 1 | likes | |
| 4 | 1 | likes | |
| 3 | 1 | dislikes | |
| 4 | 2 | dislikes | |
| 3 | 2 | likes | |
| 5 | 3 | likes |
| id | name | |
|---|---|---|
| 1 | Keanu Reeves | |
| 2 | Laurence Fishburne | |
| 3 | Carrie-Anne Moss | |
| 4 | Inigo |
| id | title | category | |
|---|---|---|---|
| 1 | Wall Street | Drama | |
| 2 | The American President | History | |
| 3 | The Shawshank Redemption | Crime |
| #!/usr/bin/python | |
| import sys | |
| import csv | |
| import sqlite3 | |
| def main(dbfile, csvfile): | |
| conn = sqlite3.connect(dbfile) | |
| conn.text_factory = str |
| from json import load, JSONEncoder | |
| from optparse import OptionParser | |
| from re import compile | |
| import os | |
| float_pat = compile(r'^-?\d+\.\d+(e-?\d+)?$') | |
| charfloat_pat = compile(r'^[\[,\,]-?\d+\.\d+(e-?\d+)?$') | |
| parser = OptionParser(usage="""%prog [options] |
| #!/usr/bin/python | |
| import sys | |
| import csv | |
| OUTPUT = "data.csv" # Output file, holding the curated set of data | |
| # Columns | |
| NAME_0 = 3 | |
| NAME_1 = 5 | |
| NAME_2 = 7 |
| #!/usr/bin/python | |
| import sys | |
| import csv | |
| import sqlite3 | |
| from os.path import basename, splitext | |
| def main(filename): | |
| dbname = splitext(basename(filename))[0] | |
| dbfile = '{filename}.sqlite'.format(filename=dbname) |