Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cron(hour=3, minute=0, second=0, run_at_startup=True)
async def save_foobar(self):
with open('foobar', 'w') as f:
f.write(f'foobar the value')
@cron(hour=3, minute=0, second=0)
async def save_spam(self):
with open('spam', 'w') as f:
f.write(f'spam the value')
@cron(hour=3, minute=0, second=0, unique=False)
async def save_not_unique(self):
with open('not_unique', 'w') as f:
f.write(f'not_unique the value')
@cron(minute={5, 35}) # run twice per hour to make sure of sending if something is wrong at one send time
async def send_event_host_updates_final(self):
"""
Send an email to the host of an event 4-5 hours before the event is scheduled to start.
"""
async with self.pg.acquire() as conn:
# get events for which updates need to be sent
events = await conn.fetch(
"""
SELECT
e.id, e.name, e.host AS host_user_id,
event_link(cat.slug, e.slug, e.public, $1) AS event_link,
cat.name AS cat_name, cat.slug AS cat_slug,
cat.company AS company_id
FROM events AS e
JOIN categories AS cat ON e.category = cat.id
WHERE e.status = 'published' AND
@cron(minute=30)
async def send_event_reminders(self):
"""
Send emails to guest of an event 24(ish) hours before the event is expected to start.
"""
async with self.pg.acquire() as conn:
# get events for which reminders need to be send
events = await conn.fetch(
"""
SELECT
e.id, e.name, e.short_description, e.start_ts, e.timezone, e.duration,
e.location_name, e.location_lat, e.location_lng,
cat.name AS cat_name, cat.slug AS cat_slug, cat.company AS company_id,
event_link(cat.slug, e.slug, e.public, $1) AS event_link,
full_name(uh.first_name, uh.last_name) AS host_name
FROM events AS e
JOIN users AS uh on e.host = uh.id
from arq import cron
async def run_regularly(ctx):
print('run foo job at 9.12am, 12.12pm and 6.12pm')
class WorkerSettings:
cron_jobs = [
cron(run_regularly, hour={9, 12, 18}, minute=12)
]
@cron(hour=7, minute=30)
async def send_event_host_updates(self):
"""
Send emails to hosts of events every day before the event with details of bookings.
"""
async with self.pg.acquire() as conn:
# get events for which updates need to be sent
events = await conn.fetch(
"""
SELECT
e.id, e.name, (e.start_ts AT TIME ZONE e.timezone)::date AS event_date, e.host AS host_user_id,
event_link(cat.slug, e.slug, e.public, $1) AS event_link,
cat.name AS cat_name, cat.slug AS cat_slug,
cat.company AS company_id, co.currency AS currency,
t_all.tickets_booked, e.ticket_limit, t_all.total_income, t_recent.tickets_booked_24h
FROM events AS e
JOIN categories AS cat ON e.category = cat.id