Exemplo n.º 1
0
def build_home(data):
    apps = data.apps

    sorted_trackers = sorted(apps.values(),
                             key=lambda a: a['overview']['reach'],
                             reverse=True)
    sorted_trackers_cat = sorted(apps.values(),
                                 key=lambda a: a.get('cat', '') or '')

    for tracker in sorted_trackers:
        if 'name' not in tracker:
            tracker['name'] = tracker['overview']['id']

    for tracker in sorted_trackers_cat:
        if 'name' not in tracker:
            tracker['name'] = tracker['overview']['id']

    # most tracked sites by cat
    most_tracked_sites = tracked_by_category(data.sites, worst=True)
    # least tracked sites by cat
    least_tracked_sites = tracked_by_category(data.sites, worst=False)

    top10 = company_reach(data.companies)
    header_graph = Markup(overview_bars(top10))

    with open('_site/index.html', 'w') as output:
        output.write(
            render_template(template=get_template(data, "index.html"),
                            ts=header_graph,
                            tracker_list=sorted_trackers[:20],
                            trackers_list_cat=sorted_trackers_cat[:20],
                            most_tracked_sites=most_tracked_sites,
                            least_tracked_sites=least_tracked_sites))

    print_progress(text="Generate home page")
Exemplo n.º 2
0
def build_company_reach_chart_page(data):
    top100 = company_reach(data.companies, n=100)
    chart = Markup(overview_bars(top100, highlight=10, custom_height=3000))
    template = get_template(data, name='reach-chart-page.html', path_to_root='..')

    with open('_site/companies/reach-chart.html', 'w') as output:
        output.write(render_template(
            path_to_root='..',
            template=template,
            chart=chart,
        ))
        print_progress(text="Generate company reach chart")
Exemplo n.º 3
0
def build_home(data):
    top10 = company_reach(data.companies)
    header_graph = Markup(overview_bars(top10))

    with open('_site/index.html', 'w') as output:
        output.write(
            render_template(
                template=get_template(data, "index.html"),
                ts=header_graph,
                tracker_list=data.trackers.sort_by(metric="reach")[:20],
                trackers_list_company=data.trackers.sort_by(
                    metric="company_id")[:20],
                most_tracked_sites=data.sites.sort_by(metric='trackers')[:20],
                least_tracked_sites=data.sites.sort_by(metric='trackers',
                                                       descending=False)[:20],
                websites=data.sites.summary_stats(),
                tracker_stats=data.trackers.summary_stats(),
                top10=top10))

    print_progress(text="Generate home page")