コード例 #1
0
def formatted_link_stats(link):
    """Pass link and clickmeta model objects ans returns a formatted dict.

    :param link:
    :param clickmeta:
    :return:
    """
    manager = ClickMetaManager()
    click_meta = manager.click_stats(link.id)
    link_info = dict(long_url=link.long_url,
                     short_code=link.short_code,
                     created_at=link.created_at)
    click_info = {
        'total_hits': click_meta.get('hits', 0),
        'country_stats': click_meta.get('country_hits', {}),
        'referrer': click_meta.get('referrer_hits', {}),
        'time_series_base': click_meta.get('time_base'),
        'time_stats': click_meta.get('timestamp_hits', {}),
    }
    return {**link_info, **click_info}
コード例 #2
0
ファイル: link.py プロジェクト: venkateshshukla/pygmy
def save_clickmeta(request, link):
    """Save public access info of short link.

    :param request:
    :param link:
    :return: ClickMeta
    """
    from pygmy.core.request_parser import parse_request, parse_header
    pygmy_header_key = config.pygmy_internal['pygmy_header_key']
    if request.headers.get('Pygmy-Header-Key') == pygmy_header_key:
        data = parse_header(request)
    else:
        data = parse_request(request)
    return ClickMetaManager().add(link_id=link.id, **data)
コード例 #3
0
ファイル: link.py プロジェクト: vaibhavmathur91/pygmy
 def get_hits_counter(self, link):
     click_manager = ClickMetaManager()
     if link and link.id:
         return click_manager.link_hit_count(dict(link_id=link.id))