feat: init commint
This commit is contained in:
201
backend/apps/tickets/migrations/0016_ticket_automation.py
Normal file
201
backend/apps/tickets/migrations/0016_ticket_automation.py
Normal file
@@ -0,0 +1,201 @@
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("agents", "0006_step_model_deployments"),
|
||||
("tickets", "0015_support_evaluation"),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="ticketdraft",
|
||||
name="blocking_missing_fields",
|
||||
field=models.JSONField(default=list),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticketdraft",
|
||||
name="blocking_questions",
|
||||
field=models.JSONField(default=list),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticketsupportanalysis",
|
||||
name="result_mode",
|
||||
field=models.CharField(default="trusted", max_length=24),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="TicketAutomationRun",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"public_id",
|
||||
models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("queued", "Queued"),
|
||||
("running", "Running"),
|
||||
("waiting_input", "Waiting input"),
|
||||
("waiting_approval", "Waiting approval"),
|
||||
("waiting_delivery", "Waiting delivery"),
|
||||
("waiting_customer", "Waiting customer"),
|
||||
("completed", "Completed"),
|
||||
("failed", "Failed"),
|
||||
("cancelled", "Cancelled"),
|
||||
],
|
||||
default="queued",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
("current_step", models.CharField(default="intake", max_length=48)),
|
||||
("policy_snapshot", models.JSONField(blank=True, default=dict)),
|
||||
("blocking_missing_fields", models.JSONField(blank=True, default=list)),
|
||||
("blocking_questions", models.JSONField(blank=True, default=list)),
|
||||
("retry_count", models.PositiveSmallIntegerField(default=0)),
|
||||
("last_error_code", models.CharField(blank=True, max_length=80)),
|
||||
("last_error_message", models.TextField(blank=True)),
|
||||
("next_action_at", models.DateTimeField(blank=True, null=True)),
|
||||
("approved_at", models.DateTimeField(blank=True, null=True)),
|
||||
("started_at", models.DateTimeField(blank=True, null=True)),
|
||||
("finished_at", models.DateTimeField(blank=True, null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"approved_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="approved_ticket_automation_runs",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"initiated_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="initiated_ticket_automation_runs",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"reply_task",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="automation_runs",
|
||||
to="tickets.customerreplytask",
|
||||
),
|
||||
),
|
||||
(
|
||||
"support_analysis",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="automation_runs",
|
||||
to="tickets.ticketsupportanalysis",
|
||||
),
|
||||
),
|
||||
(
|
||||
"ticket",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="automation_runs",
|
||||
to="tickets.ticket",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={"ordering": ["-created_at"]},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="TicketAutomationEvent",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("sequence", models.PositiveIntegerField()),
|
||||
("event_type", models.CharField(max_length=80)),
|
||||
("payload", models.JSONField(blank=True, default=dict)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
(
|
||||
"run",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="events",
|
||||
to="tickets.ticketautomationrun",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={"ordering": ["sequence"]},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ticketautomationrun",
|
||||
index=models.Index(
|
||||
fields=["ticket", "status", "created_at"],
|
||||
name="tickets_tic_ticket__f9dbaf_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ticketautomationrun",
|
||||
index=models.Index(
|
||||
fields=["status", "next_action_at"],
|
||||
name="tickets_tic_status_9ef355_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="ticketautomationrun",
|
||||
constraint=models.UniqueConstraint(
|
||||
condition=models.Q(
|
||||
status__in=[
|
||||
"queued",
|
||||
"running",
|
||||
"waiting_input",
|
||||
"waiting_approval",
|
||||
"waiting_delivery",
|
||||
"waiting_customer",
|
||||
]
|
||||
),
|
||||
fields=("ticket",),
|
||||
name="unique_active_ticket_automation_run",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ticketautomationevent",
|
||||
index=models.Index(
|
||||
fields=["run", "sequence"],
|
||||
name="tickets_tic_run_id_d6464b_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="ticketautomationevent",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("run", "sequence"),
|
||||
name="unique_ticket_automation_event_sequence",
|
||||
),
|
||||
),
|
||||
]
|
||||
22
backend/apps/tickets/migrations/0017_ticket_follow_up_of.py
Normal file
22
backend/apps/tickets/migrations/0017_ticket_follow_up_of.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("tickets", "0016_ticket_automation"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="follow_up_of",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="follow_up_tickets",
|
||||
to="tickets.ticket",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user