Example #1
0
def successful_payment(link, campaign, ip, address):
    if not address:
        return

    campaign.trans_ip = ip
    campaign.trans_billing_country = address.country

    location = location_by_ips(ip)

    if location:
        campaign.trans_ip_country = location.get("country_name")

        countries_match = campaign.trans_billing_country.lower() == campaign.trans_ip_country.lower()
        campaign.trans_country_match = countries_match

    campaign._commit()
Example #2
0
def successful_payment(link, campaign, ip, address):
    if not address:
        return

    campaign.trans_ip = ip
    campaign.trans_billing_country = address.country

    location = location_by_ips(ip)

    if location:
        campaign.trans_ip_country = location.get("country_name")

        countries_match = (campaign.trans_billing_country.lower() ==
                           campaign.trans_ip_country.lower())
        campaign.trans_country_match = countries_match

    campaign._commit()
Example #3
0
def ips_by_account_id(account_id, limit=None):
    ips = IPsByAccount.get(account_id, column_count=limit or 1000)
    flattened_ips = [j for i in ips for j in i.iteritems()]
    locations = location_by_ips(set(ip for _, ip in flattened_ips))
    orgs = organization_by_ips(set(ip for _, ip in flattened_ips))

    # Deduplicate and summarize total usage time
    counts = Counter((ip for _, ip in flattened_ips))
    seen = set()
    results = []
    for visit_time, ip in flattened_ips:
        if ip in seen:
            continue
        results.append(
            (ip, visit_time, locations.get(ip) or {},
                orgs.get(ip), counts.get(ip))
        )
        seen.add(ip)
    return results