def test_listing_returns_only_not_expired_jobs(db_connection): job1 = create_job('1', expires_at=None) job2 = create_job('2', expires_at=date(1987, 8, 30)) job3 = create_job('3', expires_at=date.today()) job4 = create_job('4', expires_at=date.today() + timedelta(days=2)) assert set(Job.listing()) == {job1, job4}
async def manage_jobs_channel(client): channel = await client.fetch_channel(JOBS_CHANNEL) jobs = list(Job.listing()) seen_links = set() async for message in channel.history(limit=None, after=None): for job in jobs: if job.link.rstrip('/') in message.content: log.info(f'Job {job.link} exists') seen_links.add(job.link) if message.reactions: job.upvotes_count = count_upvotes(message.reactions) job.downvotes_count = count_downvotes(message.reactions) with db: job.save() log.info(f'Saved {job.link} reactions') if DISCORD_MUTATIONS_ENABLED: new_jobs = [job for job in jobs if job.link not in seen_links] log.info(f'Posting {len(new_jobs)} new jobs') for job in new_jobs: await channel.send( f'**{job.title}**\n{job.company_name} – {job.location}\n{job.link}' ) else: log.warning( "Skipping Discord mutations, DISCORD_MUTATIONS_ENABLED not set")
def jobs(): with db: metrics = dict(**Metric.as_dict(), **Job.aggregate_metrics()) jobs = Job.listing() return render_template('jobs.html', nav_active='jobs', subnav_tabs=JOBS_SUBNAV_TABS, subnav_active='jobs', jobs=jobs, regions=REGIONS, metrics=metrics, thumbnail=thumbnail(title='Práce v\u00a0IT pro začátečníky'))
def jobs(): with db: jobs = Job.listing() jobs_count = Job.count() companies_count = Job.companies_count() jobs_bot = Job.bot_listing() return render_template( 'jobs.html', jobs=jobs, jobs_count=jobs_count, companies_count=companies_count, jobs_bot=jobs_bot, thumbnail=thumbnail(title='Práce v\u00a0IT pro začátečníky'))
def jobs(): with db: jobs = Job.listing() jobs_count = Job.count() companies_count = Job.companies_count() jobs_bot = Job.bot_listing() return render_template( 'jobs.html', jobs=jobs, jobs_count=jobs_count, companies_count=companies_count, jobs_bot=jobs_bot, thumbnail=thumbnail(title='Práce pro začínající programátory'))
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'))
def not_found(): with db: jobs = Job.listing() return render_template('404.html', jobs=jobs)
def test_listing_sorts_by_timestamp_desc(db): job1 = create_job('1', timestamp=datetime(2010, 7, 6, 20, 24, 3)) job2 = create_job('2', timestamp=datetime(2019, 7, 6, 20, 24, 3)) job3 = create_job('3', timestamp=datetime(2014, 7, 6, 20, 24, 3)) assert list(Job.listing()) == [job2, job3, job1]
def test_listing_returns_only_approved_jobs(db): job1 = create_job('1', is_approved=True) job2 = create_job('2', is_approved=False) job3 = create_job('3', is_approved=True) assert set(Job.listing()) == {job1, job3}
def generate_job_ids(): with db: yield from (('job', {'job_id': job.id}) for job in Job.listing())
def admin_jobs(): with db: jobs = models_to_dicts_with_metrics(Job.listing()) return render_template('admin_jobs.html', jobs=jobs)
def test_listing(db_connection): job1 = create_job('1', sort_rank=10) job2 = create_job('2', sort_rank=30) job3 = create_job('3', sort_rank=20) assert list(Job.listing()) == [job2, job3, job1]
def test_listing_returns_only_not_expired_jobs(db_connection): job1 = create_job('1', is_expired=False) job2 = create_job('2', is_expired=True) job3 = create_job('3', is_expired=False) assert set(Job.listing()) == {job1, job3}
def test_listing_sorts_by_posted_at_desc(db_connection): job1 = create_job('1', posted_at=datetime(2010, 7, 6, 20, 24, 3)) job2 = create_job('2', posted_at=datetime(2019, 7, 6, 20, 24, 3)) job3 = create_job('3', posted_at=datetime(2014, 7, 6, 20, 24, 3)) assert list(Job.listing()) == [job2, job3, job1]
def test_listing_returns_only_approved_jobs(db_connection): job1 = create_job('1', approved_at=date(1987, 8, 30)) job2 = create_job('2', approved_at=None) job3 = create_job('3', approved_at=date(1987, 8, 30)) assert set(Job.listing()) == {job1, job3}