def generate_messages(today): jobs = Job.juniorguru_listing() template_path = Path(__file__).parent / 'templates' / 'job_metrics.html' template = Template(template_path.read_text()) return (create_message(job, template, today) for job in jobs)
def test_juniorguru_listing(db_connection): job1 = create_job('1', source='juniorguru', sort_rank=30) job2 = create_job('2', source='moo') # noqa job3 = create_job('3', source='juniorguru', sort_rank=20) job4 = create_job('4', source='juniorguru', sort_rank=10) assert list(Job.juniorguru_listing()) == [job1, job3, job4]
def main(): today = date.today() jobs = Job.juniorguru_listing(today=today) jobs_count = len(jobs) log.info(f'Jobs: {jobs_count}') if jobs_count > SENDGRID_LIMIT: log.error(f'Jobs count is too high! {jobs_count} > {SENDGRID_LIMIT}') template_path = Path(__file__).parent / 'templates' / 'metrics.html' template = Template(template_path.read_text()) for job in jobs: send(create_message(today, job, template))
def generate_job_pages(): with db: for job in Job.juniorguru_listing(): yield 'job', dict(job_id=job.id)