Skip to content

Commit

Permalink
Add indices for timestamp fields of receipt models
Browse files Browse the repository at this point in the history
  • Loading branch information
emnoor-reef committed Oct 28, 2024
1 parent 65f144b commit be1f0b8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.1 on 2024-10-23 14:11
# Generated by Django 5.1.1 on 2024-10-28 12:53

import datetime

Expand All @@ -11,6 +11,28 @@ class Migration(migrations.Migration):
]

operations = [
migrations.CreateModel(
name="JobAcceptedReceipt",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("job_uuid", models.UUIDField()),
("validator_hotkey", models.CharField(max_length=256)),
("miner_hotkey", models.CharField(max_length=256)),
("validator_signature", models.CharField(max_length=256)),
("miner_signature", models.CharField(blank=True, max_length=256, null=True)),
("timestamp", models.DateTimeField()),
("time_accepted", models.DateTimeField()),
("ttl", models.IntegerField()),
],
options={
"abstract": False,
},
),
migrations.RemoveField(
model_name="jobstartedreceipt",
name="time_accepted",
Expand All @@ -37,31 +59,22 @@ class Migration(migrations.Migration):
field=models.IntegerField(default=0),
preserve_default=False,
),
migrations.CreateModel(
name="JobAcceptedReceipt",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("job_uuid", models.UUIDField()),
("validator_hotkey", models.CharField(max_length=256)),
("miner_hotkey", models.CharField(max_length=256)),
("validator_signature", models.CharField(max_length=256)),
("miner_signature", models.CharField(blank=True, max_length=256, null=True)),
("timestamp", models.DateTimeField()),
("time_accepted", models.DateTimeField()),
("ttl", models.IntegerField()),
],
options={
"abstract": False,
"constraints": [
models.UniqueConstraint(
fields=("job_uuid",), name="receipts_unique_jobacceptedreceipt_job_uuid"
)
],
},
migrations.AddIndex(
model_name="jobfinishedreceipt",
index=models.Index(fields=["timestamp"], name="jobfinishedreceipt_ts_idx"),
),
migrations.AddIndex(
model_name="jobstartedreceipt",
index=models.Index(fields=["timestamp"], name="jobstartedreceipt_ts_idx"),
),
migrations.AddIndex(
model_name="jobacceptedreceipt",
index=models.Index(fields=["timestamp"], name="jobacceptedreceipt_ts_idx"),
),
migrations.AddConstraint(
model_name="jobacceptedreceipt",
constraint=models.UniqueConstraint(
fields=("job_uuid",), name="receipts_unique_jobacceptedreceipt_job_uuid"
),
),
]
3 changes: 3 additions & 0 deletions compute_horde/compute_horde/receipts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Meta:
constraints = [
models.UniqueConstraint(fields=["job_uuid"], name="receipts_unique_%(class)s_job_uuid"),
]
indexes = [
models.Index(fields=["timestamp"], name="%(class)s_ts_idx"),
]

def __str__(self):
return f"job_uuid: {self.job_uuid}"
Expand Down

0 comments on commit be1f0b8

Please sign in to comment.