Ejemplo n.º 1
0
def test_listing_sort_by_starts_at(db_connection):
    t = date.today()
    logo1 = create_logo('1', months=12, starts_at=t - timedelta(days=6))
    logo2 = create_logo('2', months=12, starts_at=t - timedelta(days=1))
    logo3 = create_logo('3', months=12, starts_at=t - timedelta(days=3))

    assert Logo.listing() == [logo1, logo3, logo2]
Ejemplo n.º 2
0
def test_listing_only_active(db_connection):
    t = date.today()
    logo1 = create_logo('1', starts_at=t, expires_at=t + timedelta(days=30))
    logo2 = create_logo('2', starts_at=t - timedelta(days=30), expires_at=t)
    create_logo('3', starts_at=t - timedelta(days=30), expires_at=t - timedelta(days=1))
    create_logo('4', starts_at=t + timedelta(days=1), expires_at=t + timedelta(days=30))
    logo5 = create_logo('5', starts_at=t - timedelta(days=30), expires_at=t + timedelta(days=30))

    assert set(Logo.listing(today=t)) == {logo1, logo2, logo5}
Ejemplo n.º 3
0
def club():
    with db:
        members = Member.avatars_listing()
        members_total_count = Member.count()
        logos = Logo.listing()
    return render_template(
        'club.html',
        nav_active='club',
        logos=logos,
        members=members,
        members_total_count=members_total_count,
        thumbnail=thumbnail(title='Klub, který tě nastartuje'))
Ejemplo n.º 4
0
def club():
    with db:
        members = ClubUser.avatars_listing()
        members_total_count = ClubUser.members_count()
        logos = Logo.listing()
    return render_template(
        'club.html',
        nav_active='club',
        subnav_tabs=CLUB_SUBNAV_TABS,
        subnav_active='club',
        logos=logos,
        members=members,
        members_total_count=members_total_count,
        thumbnail=thumbnail(title='Klub, který tě nastartuje'))
Ejemplo n.º 5
0
def candidate_handbook():
    with db:
        jobs = Job.listing()
        jobs_remote = Job.remote_listing()
        jobs_internship = Job.internship_listing()
        jobs_volunteering = Job.volunteering_listing()
        supporters_count = Supporter.count()
        last_modified = LastModified.get_value_by_path('candidate_handbook.html')
        logos = Logo.listing()
    return render_template('candidate_handbook.html',
                           nav_active='motivation',
                           subnav_tabs=HANDBOOK_SUBNAV_TABS,
                           subnav_active='candidate_handbook',
                           jobs=jobs,
                           jobs_remote=jobs_remote,
                           jobs_internship=jobs_internship,
                           jobs_volunteering=jobs_volunteering,
                           supporters_count=supporters_count,
                           last_modified=last_modified,
                           logos=logos,
                           thumbnail=thumbnail(title='Příručka o\u00a0hledání první práce v\u00a0IT'))
Ejemplo n.º 6
0
def main():
    google_analytics_metrics = fetch_from_google_analytics()
    mailchimp_metrics = fetch_from_mailchimp()

    with db:
        Metric.drop_table()
        Metric.create_table()

        google_analytics_metric_names = [
            'avg_monthly_users',
            'avg_monthly_pageviews',
            'avg_monthly_handbook_users',
            'avg_monthly_handbook_pageviews',
            'avg_monthly_handbook_logo_clicks',
            'avg_monthly_jobs_users',
        ]
        for name in google_analytics_metric_names:
            Metric.create(name=name, value=google_analytics_metrics[name])
        Metric.create(name='subscribers',
                      value=mailchimp_metrics['subscribers'])

        JobMetric.drop_table()
        JobMetric.create_table()

        for url, value in google_analytics_metrics['users_per_job'].items():
            try:
                job = Job.get_by_url(url)
                JobMetric.create(job=job, name='users', value=value)
            except Job.DoesNotExist:
                pass

        for url, value in google_analytics_metrics['pageviews_per_job'].items(
        ):
            try:
                job = Job.get_by_url(url)
                JobMetric.create(job=job, name='pageviews', value=value)
            except Job.DoesNotExist:
                pass

        for url, value in google_analytics_metrics[
                'applications_per_job'].items():
            try:
                job = Job.get_by_url(url)
                JobMetric.create(job=job, name='applications', value=value)
            except Job.DoesNotExist:
                pass

        users_per_external_url = merge_metric_dicts(
            google_analytics_metrics['users_per_external_job'],
            mailchimp_metrics['users_per_external_url'])
        for url, value in users_per_external_url.items():
            try:
                job = Job.get_by_link(url)
                JobMetric.create(job=job, name='users', value=value)
            except Job.DoesNotExist:
                pass

        pageviews_per_external_url = merge_metric_dicts(
            google_analytics_metrics['pageviews_per_external_job'],
            mailchimp_metrics['pageviews_per_external_url'])
        for url, value in pageviews_per_external_url.items():
            try:
                job = Job.get_by_link(url)
                JobMetric.create(job=job, name='pageviews', value=value)
            except Job.DoesNotExist:
                pass

        LogoMetric.drop_table()
        LogoMetric.create_table()

        for url, value in google_analytics_metrics['clicks_per_logo'].items():
            try:
                logo = Logo.get_by_url(url)
                LogoMetric.create(logo=logo, name='clicks', value=value)
            except Logo.DoesNotExist:
                pass

        for logo in Logo.listing():
            values = google_analytics_metrics['handbook_users_per_date']
            metric = LogoMetric.from_values_per_date(logo, 'users', values)
            metric.save()
            values = google_analytics_metrics['handbook_pageviews_per_date']
            metric = LogoMetric.from_values_per_date(logo, 'pageviews', values)
            metric.save()
Ejemplo n.º 7
0
def test_listing_sort_by_months(db_connection):
    logo1 = create_logo('1', months=12)
    logo2 = create_logo('2', months=3)
    logo3 = create_logo('3', months=6)

    assert Logo.listing() == [logo1, logo3, logo2]