Skip to content

Instantly share code, notes, and snippets.

@tlpriest
Created June 28, 2024 14:08
Show Gist options
  • Save tlpriest/f3f764eeeee31a440b5401ce3c9283ba to your computer and use it in GitHub Desktop.
Save tlpriest/f3f764eeeee31a440b5401ce3c9283ba to your computer and use it in GitHub Desktop.
schedule = CrontabSchedule.objects.create(
minute=self.minute,
hour=self.hour,
day_of_week=",".join([str(x) for x in self.days_of_week]),
timezone=self.team.timezone,
)
pt, _ = PeriodicTask.objects.update_or_create(
name=name,
defaults={
"task": "app.api.dofun.tasks.topics.check_for_rain",
"args": json.dumps([{"team_id": self.team.id, "schema_name": connection.tenant.schema_name}]),
"crontab": schedule,
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment