From 57364148cfc22d77f67b800085d53685cf4bce83 Mon Sep 17 00:00:00 2001 From: TannedCung Date: Mon, 4 Nov 2024 14:11:09 +0700 Subject: [PATCH] Indexing DB --- cope2n-api/fwd_api/models/SubscriptionRequest.py | 2 +- cope2n-api/fwd_api/models/SubscriptionRequestFile.py | 7 +++++++ cope2n-api/fwd_api/models/UserProfile.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cope2n-api/fwd_api/models/SubscriptionRequest.py b/cope2n-api/fwd_api/models/SubscriptionRequest.py index 80bb44f..0b89fdf 100755 --- a/cope2n-api/fwd_api/models/SubscriptionRequest.py +++ b/cope2n-api/fwd_api/models/SubscriptionRequest.py @@ -8,7 +8,7 @@ class SubscriptionRequest(models.Model): pages: int = models.IntegerField() pages_left: int = models.IntegerField(default=1) doc_type: str = models.CharField(max_length=100) - request_id = models.CharField(max_length=200) # Change to request_id + request_id = models.CharField(max_length=200, db_index=True) # Change to request_id redemption_id = models.CharField(max_length=200, null=True) process_type = models.CharField(max_length=200) # driver/id/invoice provider_code = models.CharField(max_length=200, default="Guest") # Request source FWD/CTel diff --git a/cope2n-api/fwd_api/models/SubscriptionRequestFile.py b/cope2n-api/fwd_api/models/SubscriptionRequestFile.py index bed1a31..e9ffc22 100755 --- a/cope2n-api/fwd_api/models/SubscriptionRequestFile.py +++ b/cope2n-api/fwd_api/models/SubscriptionRequestFile.py @@ -35,3 +35,10 @@ class SubscriptionRequestFile(models.Model): feedback_accuracy = models.JSONField(null=True) reviewed_accuracy = models.JSONField(null=True) + + class Meta: + indexes = [ + models.Index(fields=['request', 'index_in_request', 'doc_type']), # For updating results + models.Index(fields=['request', 'file_name']), # for getting image files by AI + ] + diff --git a/cope2n-api/fwd_api/models/UserProfile.py b/cope2n-api/fwd_api/models/UserProfile.py index 6b91ad7..81e5abe 100755 --- a/cope2n-api/fwd_api/models/UserProfile.py +++ b/cope2n-api/fwd_api/models/UserProfile.py @@ -6,7 +6,7 @@ from fwd_api.constant.common import EntityStatus class UserProfile(models.Model): - id = models.AutoField(primary_key=True) + id = models.AutoField(primary_key=True, db_index=True) user_name: str = models.CharField(max_length=200, null=True) password: str = models.CharField(max_length=200, null=True) full_name: str = models.CharField(max_length=200, null=True)