|
4 | 4 | from django.contrib.postgres.aggregates import ArrayAgg |
5 | 5 | from django.contrib.postgres.fields import ArrayField |
6 | 6 | from django.db import models |
7 | | -from django.db.models import Count, JSONField |
| 7 | +from django.db.models import Count, JSONField, Q |
8 | 8 | from django.db.models.fields.json import KeyTextTransform |
9 | 9 | from fyle_accounting_library.fyle_platform.constants import IMPORTED_FROM_CHOICES |
10 | 10 | from fyle_accounting_library.fyle_platform.enums import ExpenseImportSourceEnum |
11 | 11 | from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin |
12 | 12 | from fyle_accounting_mappings.models import ExpenseAttribute |
13 | 13 |
|
14 | 14 | from apps.users.models import User |
| 15 | +from apps.workspaces.enums import ( |
| 16 | + ExportTypeEnum, |
| 17 | + SystemCommentEntityTypeEnum, |
| 18 | + SystemCommentIntentEnum, |
| 19 | + SystemCommentReasonEnum, |
| 20 | + SystemCommentSourceEnum, |
| 21 | +) |
15 | 22 | from apps.workspaces.models import Configuration, Workspace |
16 | 23 | from apps.workspaces.system_comments import add_system_comment |
17 | | -from apps.workspaces.enums import ExportTypeEnum, SystemCommentEntityTypeEnum, SystemCommentIntentEnum, SystemCommentReasonEnum, SystemCommentSourceEnum |
18 | 24 |
|
19 | 25 | ALLOWED_FIELDS = [ |
20 | 26 | 'employee_email', 'report_id', 'claim_number', 'settlement_id', |
@@ -490,6 +496,13 @@ class ExpenseGroup(models.Model): |
490 | 496 |
|
491 | 497 | class Meta: |
492 | 498 | db_table = 'expense_groups' |
| 499 | + indexes = [ |
| 500 | + models.Index( |
| 501 | + fields=['workspace_id', 'fund_source'], |
| 502 | + condition=Q(exported_at__isnull=True), |
| 503 | + name='eg_ws_fund_null_idx', |
| 504 | + ), |
| 505 | + ] |
493 | 506 |
|
494 | 507 | @staticmethod |
495 | 508 | def create_expense_groups_by_report_id_fund_source(expense_objects: list[Expense], configuration: Configuration, workspace_id: int, system_comments: list = None) -> None: |
|
0 commit comments