Skip to content

Commit

Permalink
Merge branch 'master' into handle-posted-at
Browse files Browse the repository at this point in the history
  • Loading branch information
anishfyle committed Nov 17, 2024
2 parents 57258e0 + b4c1d86 commit 17ac116
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
20 changes: 20 additions & 0 deletions apps/tasks/migrations/0012_alter_tasklog_expense_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.14 on 2024-11-14 10:33

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('fyle', '0038_expensegroup_export_url'),
('tasks', '0011_error_repetition_count'),
]

operations = [
migrations.AlterField(
model_name='tasklog',
name='expense_group',
field=models.ForeignKey(help_text='Reference to Expense group', null=True, on_delete=django.db.models.deletion.PROTECT, to='fyle.expensegroup', unique=True),
),
]
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')
expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group', unique=True)
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: 10 additions & 2 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
from datetime import date, datetime, timedelta
from typing import List

from django.conf import settings
Expand Down Expand Up @@ -65,7 +65,15 @@ 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()})
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),
}
)

ws_schedule.schedule = schedule

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ psycopg2-binary==2.8.4
pylint==2.7.4
python-dateutil==2.8.1
pytz==2019.3
qbosdk==0.18.1
qbosdk==0.19.0
redis==3.3.11
requests==2.25.0
sentry-sdk==1.19.1
Expand Down

0 comments on commit 17ac116

Please sign in to comment.