コード例 #1
0
ファイル: statistics.py プロジェクト: dmorley/social-relay
def get_subscriber_stats():
    stats = {
        "total": 0,
        "subscribers": {
            "total": 0,
            "all": 0,
            "tags": 0,
        },
        "tags": [],
    }
    tags = []
    for pod, data in get_pod_preferences().items():
        data = json.loads(data.decode("utf-8"))
        try:
            stats["total"] += 1
            if data["subscribe"]:
                stats["subscribers"]["total"] += 1
                if data["scope"] == "all":
                    stats["subscribers"]["all"] += 1
                elif data["scope"] == "tags":
                    stats["subscribers"]["tags"] += 1
                tags += data["tags"]
        except KeyError:
            pass
    stats["tags"] = set(tags)
    return stats
コード例 #2
0
ファイル: receive.py プロジェクト: candango/social-relay
def pods_who_want_all():
    pods = []
    for pod, data in get_pod_preferences().items():
        data = json.loads(data.decode("utf-8"))
        if data["subscribe"] and data["scope"] == "all":
            pods.append(pod.decode("utf-8"))
    return pods
コード例 #3
0
ファイル: statistics.py プロジェクト: royalterra/social-relay
def get_subscriber_stats():
    stats = {
        "total": 0,
        "subscribers": {
            "total": 0,
            "all": 0,
            "tags": 0,
        },
        "tags": [],
    }
    tags = []
    for pod, data in get_pod_preferences().items():
        data = json.loads(data.decode("utf-8"))
        try:
            stats["total"] += 1
            if data["subscribe"]:
                stats["subscribers"]["total"] += 1
                if data["scope"] == "all":
                    stats["subscribers"]["all"] += 1
                elif data["scope"] == "tags":
                    stats["subscribers"]["tags"] += 1
                tags += data["tags"]
        except KeyError:
            pass
    stats["tags"] = set(tags)
    return stats
コード例 #4
0
ファイル: receive.py プロジェクト: candango/social-relay
def pods_who_want_tags(tags):
    pods = []
    for pod, data in get_pod_preferences().items():
        data = json.loads(data.decode("utf-8"))
        if not set(data["tags"]).isdisjoint(tags):
            # One or more tags match
            pods.append(pod.decode("utf-8"))
    return pods