def CDNs(embeds, service, rMin, rMax): return countToRating( embeds.filter( Q(embed_type=ServiceThirdPartyEmbeds.ONVIEW) & ((~Q(thirdparty__sector="tracker") & ~Q(thirdparty__sector="unkown")) | Q(thirdparty__name=service.name))).count(), rMin, rMax, )
def calculatePersonalizedLinksThirdParties( embeds, service, rMin, rMax): # TODO should I filter the links to the newsletters own site? return countToRating( embeds.filter((Q(embed_type=ServiceThirdPartyEmbeds.ONCLICK) | Q(embed_type=ServiceThirdPartyEmbeds.STATIC)) & ~Q(thirdparty__name=service.name) & Q(receives_identifier=True)).count(), rMin, rMax, )
def highNumber(embeds, service, rMin, rMax): return countToRating( embeds.filter((( Q(embed_type=ServiceThirdPartyEmbeds.ONVIEW) & (Q(thirdparty__sector="tracker") | Q(thirdparty__sector="unkown"))) | (Q(embed_type=ServiceThirdPartyEmbeds.ONCLICK) & (Q(thirdparty__sector="tracker") | Q(thirdparty__sector="unkown"))) & Q(thirdparty__name=service.name))).count(), rMin, rMax, )
def CDNs(service, rMin, rMax): return countToRating( len( filterDict( service["third_parties"], lambda key, value: "ONVIEW" in value["embed_as"] and ( (key.sector != "tracker" and key.sector != "unknown" ) or key.name == service["service"].name), )), rMin, rMax, )
def toTrackers(service, rMin, rMax): return countToRating( len( filterDict( service["third_parties"], lambda key, value: "ONCLICK" in value["embed_as"] and key.name != service["service"].name and ( key.sector == "tracker" ), # This unknown might be over sensitv because a lot of thirdparties are not classified yet )), rMin, rMax, )
def highNumber(service, rMin, rMax): return countToRating( len( filterDict( service["third_parties"], lambda key, value: (("ONVIEW" in value["embed_as"] and (key.sector == "tracker" or key.sector == "unknown")) or ("ONCLICK" in value["embed_as"] and (key.sector == "tracker") )) and key.name != service["service"].name, )), rMin, rMax, )
def calculatePersonalizedLinksThirdParties( service, rMin, rMax ): # TODO should I filter the links to the newsletters own site? return countToRating( len( filterDict( service["third_parties"], lambda key, value: "ONCLICK" in value["embed_as"] and key.name != service["service"].name and value["receives_identifier"], ) ), rMin, rMax, )
def trackers(embeds, service, rMin, rMax): tracker_embeds = embeds.filter( ((Q(embed_type=ServiceThirdPartyEmbeds.ONVIEW) & (Q(thirdparty__sector="tracker") | Q(thirdparty__sector="unkown"))) | (Q(embed_type=ServiceThirdPartyEmbeds.ONCLICK) & (Q(thirdparty__sector="tracker") | Q(thirdparty__sector="unkown"))) & Q(thirdparty__name=service.name))).distinct(), big = 0 small = 0 for tracker_embed in tracker_embeds[0]: if Service.objects.filter( thirdparties=tracker_embed.thirdparty).count() > 10: big = big + 1 else: small = small + 1 return countToRating( big * 2 + small, rMin, rMax, )
def toThirdParties( service, rMin, rMax): # TODO should I filter the links to the newsletters own site? diffrentCountries = len( filterDict( service["third_parties"], lambda key, value: "ONCLICK" in value["embed_as"] and key.name != service["service"].name and not value["receives_identifier"] and key.country_of_origin != service["service"].country_of_origin, )) sameCountry = len( filterDict( service["third_parties"], lambda key, value: "ONCLICK" in value["embed_as"] and key.name != service["service"].name and not value["receives_identifier"] and key.country_of_origin == service["service"].country_of_origin, )) return countToRating( diffrentCountries * 1.5 + sameCountry, rMin, rMax, )
def trackers(service, rMin, rMax): return countToRating( bigTrackers(service) * 2 + smallTrackers(service), rMin, rMax, )