2023-11-30 11:19:06 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils import timezone
|
2024-11-28 09:45:06 +00:00
|
|
|
from django.contrib.postgres.indexes import GinIndex
|
2023-11-30 11:19:06 +00:00
|
|
|
|
|
|
|
from fwd_api.models.Subscription import Subscription
|
|
|
|
|
|
|
|
class SubscriptionRequest(models.Model):
|
|
|
|
id = models.AutoField(primary_key=True)
|
|
|
|
pages: int = models.IntegerField()
|
2023-12-08 12:49:00 +00:00
|
|
|
pages_left: int = models.IntegerField(default=1)
|
2024-11-28 09:45:06 +00:00
|
|
|
doc_type: str = models.CharField(max_length=100, db_index=True)
|
2024-11-04 07:11:09 +00:00
|
|
|
request_id = models.CharField(max_length=200, db_index=True) # Change to request_id
|
2024-01-11 10:38:12 +00:00
|
|
|
redemption_id = models.CharField(max_length=200, null=True)
|
2023-11-30 11:19:06 +00:00
|
|
|
process_type = models.CharField(max_length=200) # driver/id/invoice
|
|
|
|
provider_code = models.CharField(max_length=200, default="Guest") # Request source FWD/CTel
|
|
|
|
predict_result = models.JSONField(null=True)
|
2023-12-08 12:49:00 +00:00
|
|
|
feedback_result = models.JSONField(null=True)
|
2024-01-05 07:18:16 +00:00
|
|
|
reviewed_result = models.JSONField(null=True)
|
2023-11-30 11:19:06 +00:00
|
|
|
status = models.IntegerField() # 1: Processing(Pending) 2: PredictCompleted 3: ReturnCompleted
|
|
|
|
subscription = models.ForeignKey(Subscription, on_delete=models.CASCADE)
|
2023-12-15 05:43:19 +00:00
|
|
|
created_at = models.DateTimeField(default=timezone.now, db_index=True)
|
2023-12-25 03:32:09 +00:00
|
|
|
updated_at = models.DateTimeField(auto_now=True)
|
2023-12-21 10:31:55 +00:00
|
|
|
is_test_request = models.BooleanField(default=False)
|
2023-12-25 03:32:09 +00:00
|
|
|
S3_uploaded = models.BooleanField(default=False)
|
2024-01-31 03:00:18 +00:00
|
|
|
|
|
|
|
feedback_accuracy = models.JSONField(null=True)
|
|
|
|
reviewed_accuracy = models.JSONField(null=True)
|
2024-04-22 12:49:02 +00:00
|
|
|
raw_accuracy = models.FloatField(default=None, null=True)
|
2023-12-21 10:31:55 +00:00
|
|
|
|
2023-12-29 07:24:52 +00:00
|
|
|
ai_inference_profile = models.JSONField(null=True)
|
2023-12-21 10:31:55 +00:00
|
|
|
preprocessing_time = models.FloatField(default=-1)
|
2024-01-05 07:18:16 +00:00
|
|
|
client_request_time = models.FloatField(default=-1)
|
2023-12-22 07:03:56 +00:00
|
|
|
ai_inference_start_time = models.FloatField(default=0)
|
|
|
|
ai_inference_time = models.FloatField(default=0)
|
2023-12-21 10:31:55 +00:00
|
|
|
cpu_percent = models.FloatField(default=-1)
|
|
|
|
gpu_percent = models.FloatField(default=-1)
|
|
|
|
used_memory = models.FloatField(default=-1)
|
|
|
|
total_memory = models.FloatField(default=-1)
|
|
|
|
gpu_stats = models.CharField(max_length=100, null=True)
|
|
|
|
is_reviewed = models.BooleanField(default=False)
|
2024-05-17 12:39:31 +00:00
|
|
|
is_required = models.BooleanField(default=True)
|
2024-03-29 11:34:02 +00:00
|
|
|
subsidiary = models.CharField(default="", null=True, max_length=200)
|
2024-11-28 09:45:06 +00:00
|
|
|
|
|
|
|
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'),
|
|
|
|
]
|