Skip to content

Commit

Permalink
Revert "fix: add unique constraint in task_logs for expense_group, ad…
Browse files Browse the repository at this point in the history
…d interval for next run (#690)"

This reverts commit d1d12fd.
  • Loading branch information
Hrishabh17 committed Nov 19, 2024
1 parent b301368 commit cde9c60
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
20 changes: 0 additions & 20 deletions apps/tasks/migrations/0012_alter_tasklog_expense_group.py

This file was deleted.

2 changes: 1 addition & 1 deletion apps/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TaskLog(models.Model):
workspace = models.ForeignKey(Workspace, on_delete=models.PROTECT, help_text='Reference to Workspace model')
type = models.CharField(max_length=50, help_text='Task type (FETCH_EXPENSES / CREATE_BILL / CREATE_CHECK)')
task_id = models.CharField(max_length=255, null=True, help_text='Django Q task reference')
expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group', unique=True)
expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group')
bill = models.ForeignKey(Bill, on_delete=models.PROTECT, help_text='Reference to Bill', null=True)
cheque = models.ForeignKey(Cheque, on_delete=models.PROTECT, help_text='Reference to Cheque', null=True)
journal_entry = models.ForeignKey(JournalEntry, on_delete=models.PROTECT, help_text='Reference to journal_entry', null=True)
Expand Down
12 changes: 2 additions & 10 deletions apps/workspaces/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from datetime import date, datetime, timedelta
from datetime import date, datetime
from typing import List

from django.conf import settings
Expand Down Expand Up @@ -65,15 +65,7 @@ def schedule_sync(workspace_id: int, schedule_enabled: bool, hours: int, email_a
if email_added:
ws_schedule.additional_email_options.append(email_added)

schedule, _ = Schedule.objects.update_or_create(
func='apps.workspaces.tasks.run_sync_schedule',
args='{}'.format(workspace_id),
defaults={
'schedule_type': Schedule.MINUTES,
'minutes': hours * 60,
'next_run': datetime.now() + timedelta(hours=hours),
}
)
schedule, _ = Schedule.objects.update_or_create(func='apps.workspaces.tasks.run_sync_schedule', args='{}'.format(workspace_id), defaults={'schedule_type': Schedule.MINUTES, 'minutes': hours * 60, 'next_run': datetime.now()})

ws_schedule.schedule = schedule

Expand Down

0 comments on commit cde9c60

Please sign in to comment.