-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ashutosh619-sudo
committed
Nov 27, 2023
1 parent
24fabfa
commit cc17962
Showing
2 changed files
with
34 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from apps.tasks.models import TaskLog | ||
from apps.workspaces.models import LastExportDetail | ||
from django.db.models import Q | ||
|
||
|
||
def update_last_export_details(workspace_id): | ||
last_export_detail = LastExportDetail.objects.get(workspace_id=workspace_id) | ||
|
||
failed_exports = TaskLog.objects.filter( | ||
~Q(type__in=['CREATING_VENDOR_PAYMENT','FETCHING_EXPENSES']), workspace_id=workspace_id, status__in=['FAILED', 'FATAL'] | ||
).count() | ||
|
||
successful_exports = TaskLog.objects.filter( | ||
~Q(type__in=['CREATING_VENDOR_PAYMENT', 'FETCHING_EXPENSES']), | ||
workspace_id=workspace_id, | ||
status='COMPLETE', | ||
updated_at__gt=last_export_detail.last_exported_at | ||
).count() | ||
|
||
last_export_detail.failed_expense_groups_count = failed_exports | ||
last_export_detail.successful_expense_groups_count = successful_exports | ||
last_export_detail.total_expense_groups_count = failed_exports + successful_exports | ||
last_export_detail.save() | ||
|
||
return last_export_detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters