From 669bef95289889aac6c809d2fedc0119b78d6a94 Mon Sep 17 00:00:00 2001 From: TannedCung Date: Tue, 5 Nov 2024 09:56:30 +0700 Subject: [PATCH 01/13] Add migrations --- ...subscriptionrequest_request_id_and_more.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cope2n-api/fwd_api/migrations/0195_alter_subscriptionrequest_request_id_and_more.py diff --git a/cope2n-api/fwd_api/migrations/0195_alter_subscriptionrequest_request_id_and_more.py b/cope2n-api/fwd_api/migrations/0195_alter_subscriptionrequest_request_id_and_more.py new file mode 100644 index 0000000..175920c --- /dev/null +++ b/cope2n-api/fwd_api/migrations/0195_alter_subscriptionrequest_request_id_and_more.py @@ -0,0 +1,31 @@ +# Generated by Django 4.1.3 on 2024-11-05 02:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fwd_api', '0194_alter_semiautocorrection_feedback_accuracy_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='subscriptionrequest', + name='request_id', + field=models.CharField(db_index=True, max_length=200), + ), + migrations.AlterField( + model_name='userprofile', + name='id', + field=models.AutoField(db_index=True, primary_key=True, serialize=False), + ), + migrations.AddIndex( + model_name='subscriptionrequestfile', + index=models.Index(fields=['request', 'index_in_request', 'doc_type'], name='fwd_api_sub_request_890e13_idx'), + ), + migrations.AddIndex( + model_name='subscriptionrequestfile', + index=models.Index(fields=['request', 'file_name'], name='fwd_api_sub_request_1a42cd_idx'), + ), + ] \ No newline at end of file From a282e9c5052a2ecdf0bce576db60dfaf5fd80a7a Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 28 Nov 2024 16:44:39 +0700 Subject: [PATCH 02/13] Add: filter to search --- cope2n-api/fwd_api/api/accuracy_view.py | 42 ++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/cope2n-api/fwd_api/api/accuracy_view.py b/cope2n-api/fwd_api/api/accuracy_view.py index e4295f0..ec48e65 100755 --- a/cope2n-api/fwd_api/api/accuracy_view.py +++ b/cope2n-api/fwd_api/api/accuracy_view.py @@ -112,6 +112,34 @@ class AccuracyViewSet(viewsets.ViewSet): type=OpenApiTypes.FLOAT, required=False ), + OpenApiParameter( + name='predict_result', + location=OpenApiParameter.QUERY, + description='Filter by predict result', + type=OpenApiTypes.STR, + required=False + ), + OpenApiParameter( + name='feedback_result', + location=OpenApiParameter.QUERY, + description='Filter by feedback result', + type=OpenApiTypes.STR, + required=False + ), + OpenApiParameter( + name='reviewed_result', + location=OpenApiParameter.QUERY, + description='Filter by reviewed result', + type=OpenApiTypes.STR, + required=False + ), + OpenApiParameter( + name='doc_type', + location=OpenApiParameter.QUERY, + description='Filter by document type', + type=OpenApiTypes.STR, + required=False + ), ], responses=None, tags=['Accuracy'] ) @@ -129,7 +157,10 @@ class AccuracyViewSet(viewsets.ViewSet): include_test = request.GET.get('includes_test', False) subsidiary = request.GET.get("subsidiary", "all") max_accuracy = float(request.GET.get("max_accuracy", 100)) - # subsidiary = map_subsidiary_long_to_short(subsidiary) + predict_result = request.GET.get('predict_result', None) + feedback_result = request.GET.get('feedback_result', None) + reviewed_result = request.GET.get('reviewed_result', None) + doc_type = request.GET.get('doc_type', None) base_query = Q(status=200) if start_date_str or end_date_str: @@ -193,6 +224,15 @@ class AccuracyViewSet(viewsets.ViewSet): base_query &= Q( redemption_id__startswith=map_subsidiary_long_to_short(subsidiary)) + if predict_result: + base_query &= Q(predict_result__icontains=predict_result) + if feedback_result: + base_query &= Q(feedback_result__icontains=feedback_result) + if reviewed_result: + base_query &= Q(reviewed_result__icontains=reviewed_result) + if doc_type: + base_query &= Q(doc_type__icontains=doc_type) + if isinstance(max_accuracy, float): base_query &= Q(raw_accuracy__lt=( max_accuracy/100)) | Q(raw_accuracy__isnull=True) From 69ac10dec36a5d8fa1f7c6469f52b4918feba3ab Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 28 Nov 2024 16:45:06 +0700 Subject: [PATCH 03/13] Add: model index and migrations --- ...estfile_idx_gin_predict_result_and_more.py | 26 +++++++++++++++++++ ...uest_idx_gin_rq_predict_result_and_more.py | 26 +++++++++++++++++++ ...0198_alter_subscriptionrequest_doc_type.py | 18 +++++++++++++ .../fwd_api/models/SubscriptionRequest.py | 10 ++++++- .../fwd_api/models/SubscriptionRequestFile.py | 5 +++- 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 cope2n-api/fwd_api/migrations/0196_subscriptionrequestfile_idx_gin_predict_result_and_more.py create mode 100644 cope2n-api/fwd_api/migrations/0197_subscriptionrequest_idx_gin_rq_predict_result_and_more.py create mode 100644 cope2n-api/fwd_api/migrations/0198_alter_subscriptionrequest_doc_type.py 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'), ] From dbf9a889da9c235b0895a2b5ec84cce42a39f76c Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 28 Nov 2024 16:45:32 +0700 Subject: [PATCH 04/13] Fix: Build error --- cope2n-fe/package.json | 2 +- cope2n-fe/src/pages/reviews2/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cope2n-fe/package.json b/cope2n-fe/package.json index a05845f..fb1b005 100644 --- a/cope2n-fe/package.json +++ b/cope2n-fe/package.json @@ -83,7 +83,7 @@ "prettier-plugin-organize-imports": "^3.2.1", "rollup-plugin-visualizer": "^5.9.0", "sass": "^1.57.1", - "typescript": "5.6.3", + "typescript": "^5.6.3", "vite": "^4.0.3", "vite-plugin-svgr": "^2.4.0", "vite-tsconfig-paths": "^4.0.3" diff --git a/cope2n-fe/src/pages/reviews2/index.tsx b/cope2n-fe/src/pages/reviews2/index.tsx index 2f73edb..28646be 100644 --- a/cope2n-fe/src/pages/reviews2/index.tsx +++ b/cope2n-fe/src/pages/reviews2/index.tsx @@ -875,7 +875,7 @@ const ReviewPage = () => {
+ {/* add 4 more filter fields */} +
+ + setFilterFeedbackResult(e.target.value)} + /> + +
+
+ + setFilterPredictResult(e.target.value)} + /> + + + setFilterReviewedResult(e.target.value)} + /> + +
Date: Tue, 3 Dec 2024 16:47:10 +0700 Subject: [PATCH 08/13] [yagin]add key for SOURCE_KEYS list --- cope2n-fe/src/pages/reviews2/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cope2n-fe/src/pages/reviews2/index.tsx b/cope2n-fe/src/pages/reviews2/index.tsx index f38b0d2..e0ffa3d 100644 --- a/cope2n-fe/src/pages/reviews2/index.tsx +++ b/cope2n-fe/src/pages/reviews2/index.tsx @@ -788,7 +788,7 @@ const ReviewPage = () => { } } catch (error) {} return ( -
+
Date: Wed, 4 Dec 2024 10:57:02 +0700 Subject: [PATCH 09/13] [yagin]add condition render for viewer component --- cope2n-fe/src/pages/reviews2/index.tsx | 43 +++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/cope2n-fe/src/pages/reviews2/index.tsx b/cope2n-fe/src/pages/reviews2/index.tsx index e0ffa3d..f192984 100644 --- a/cope2n-fe/src/pages/reviews2/index.tsx +++ b/cope2n-fe/src/pages/reviews2/index.tsx @@ -416,18 +416,18 @@ const ReviewPage = () => { style={ fullscreen ? { - position: 'fixed', - top: 0, - left: 0, - width: '100%', - height: '100%', - backgroundColor: '#fff', - zIndex: 1000, - } + position: 'fixed', + top: 0, + left: 0, + width: '100%', + height: '100%', + backgroundColor: '#fff', + zIndex: 1000, + } : { - height: '100%', - position: 'relative', - } + height: '100%', + position: 'relative', + } } >
{ overflow: 'auto', }} > - setImageLoading(false)} - /> + />}
) : (
{ >