diff --git a/cope2n-api/fwd_api/migrations/0196_subscriptionrequestfile_idx_gin_predict_result_and_more.py b/cope2n-api/fwd_api/migrations/0196_subscriptionrequestfile_idx_gin_predict_result_and_more.py new file mode 100644 index 0000000..561ddaf --- /dev/null +++ b/cope2n-api/fwd_api/migrations/0196_subscriptionrequestfile_idx_gin_predict_result_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 4.1.3 on 2024-11-28 07:10 + +import django.contrib.postgres.indexes +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('fwd_api', '0195_alter_subscriptionrequest_request_id_and_more'), + ] + + operations = [ + migrations.AddIndex( + model_name='subscriptionrequestfile', + index=django.contrib.postgres.indexes.GinIndex(fields=['predict_result'], name='idx_gin_predict_result'), + ), + migrations.AddIndex( + model_name='subscriptionrequestfile', + index=django.contrib.postgres.indexes.GinIndex(fields=['feedback_result'], name='idx_gin_feedback_result'), + ), + migrations.AddIndex( + model_name='subscriptionrequestfile', + index=django.contrib.postgres.indexes.GinIndex(fields=['reviewed_result'], name='idx_gin_reviewed_result'), + ), + ] diff --git a/cope2n-api/fwd_api/migrations/0197_subscriptionrequest_idx_gin_rq_predict_result_and_more.py b/cope2n-api/fwd_api/migrations/0197_subscriptionrequest_idx_gin_rq_predict_result_and_more.py new file mode 100644 index 0000000..3a8f521 --- /dev/null +++ b/cope2n-api/fwd_api/migrations/0197_subscriptionrequest_idx_gin_rq_predict_result_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 4.1.3 on 2024-11-28 09:04 + +import django.contrib.postgres.indexes +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('fwd_api', '0196_subscriptionrequestfile_idx_gin_predict_result_and_more'), + ] + + operations = [ + migrations.AddIndex( + model_name='subscriptionrequest', + index=django.contrib.postgres.indexes.GinIndex(fields=['predict_result'], name='idx_gin_rq_predict_result'), + ), + migrations.AddIndex( + model_name='subscriptionrequest', + index=django.contrib.postgres.indexes.GinIndex(fields=['feedback_result'], name='idx_gin_rq_feedback_result'), + ), + migrations.AddIndex( + model_name='subscriptionrequest', + index=django.contrib.postgres.indexes.GinIndex(fields=['reviewed_result'], name='idx_gin_rq_reviewed_result'), + ), + ] diff --git a/cope2n-api/fwd_api/migrations/0198_alter_subscriptionrequest_doc_type.py b/cope2n-api/fwd_api/migrations/0198_alter_subscriptionrequest_doc_type.py new file mode 100644 index 0000000..c553826 --- /dev/null +++ b/cope2n-api/fwd_api/migrations/0198_alter_subscriptionrequest_doc_type.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.3 on 2024-11-28 09:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fwd_api', '0197_subscriptionrequest_idx_gin_rq_predict_result_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='subscriptionrequest', + name='doc_type', + field=models.CharField(db_index=True, max_length=100), + ), + ] diff --git a/cope2n-api/fwd_api/models/SubscriptionRequest.py b/cope2n-api/fwd_api/models/SubscriptionRequest.py index 0b89fdf..24fc53b 100755 --- a/cope2n-api/fwd_api/models/SubscriptionRequest.py +++ b/cope2n-api/fwd_api/models/SubscriptionRequest.py @@ -1,5 +1,6 @@ from django.db import models from django.utils import timezone +from django.contrib.postgres.indexes import GinIndex from fwd_api.models.Subscription import Subscription @@ -7,7 +8,7 @@ class SubscriptionRequest(models.Model): id = models.AutoField(primary_key=True) pages: int = models.IntegerField() pages_left: int = models.IntegerField(default=1) - doc_type: str = models.CharField(max_length=100) + doc_type: str = models.CharField(max_length=100, db_index=True) 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 @@ -39,3 +40,10 @@ class SubscriptionRequest(models.Model): is_reviewed = models.BooleanField(default=False) is_required = models.BooleanField(default=True) subsidiary = models.CharField(default="", null=True, max_length=200) + + class Meta: + indexes = [ + GinIndex(fields=['predict_result'], name='idx_gin_rq_predict_result'), + GinIndex(fields=['feedback_result'], name='idx_gin_rq_feedback_result'), + GinIndex(fields=['reviewed_result'], name='idx_gin_rq_reviewed_result'), + ] \ No newline at end of file diff --git a/cope2n-api/fwd_api/models/SubscriptionRequestFile.py b/cope2n-api/fwd_api/models/SubscriptionRequestFile.py index e9ffc22..1dce06d 100755 --- a/cope2n-api/fwd_api/models/SubscriptionRequestFile.py +++ b/cope2n-api/fwd_api/models/SubscriptionRequestFile.py @@ -1,5 +1,5 @@ from django.db import models - +from django.contrib.postgres.indexes import GinIndex from fwd_api.constant.common import FileCategory from fwd_api.models import SubscriptionRequest from fwd_api.models.fields.EncryptedCharField import EncryptedCharField @@ -40,5 +40,8 @@ class SubscriptionRequestFile(models.Model): 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 + GinIndex(fields=['predict_result'], name='idx_gin_predict_result'), + GinIndex(fields=['feedback_result'], name='idx_gin_feedback_result'), + GinIndex(fields=['reviewed_result'], name='idx_gin_reviewed_result'), ]