mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-04 12:08:11 +08:00
Add index on succeeded tasks (#164)
* Add index on task table * also add models file * add make commands and limit index * format
This commit is contained in:
@@ -4,6 +4,15 @@ dev:
|
|||||||
test:
|
test:
|
||||||
docker-compose -f test-services-docker-compose.yaml run --rm django-q2 poetry run pytest
|
docker-compose -f test-services-docker-compose.yaml run --rm django-q2 poetry run pytest
|
||||||
|
|
||||||
|
shell:
|
||||||
|
docker-compose -f test-services-docker-compose.yaml run --rm django-q2 poetry run python manage.py shell
|
||||||
|
|
||||||
|
makemigrations:
|
||||||
|
docker-compose -f test-services-docker-compose.yaml run --rm django-q2 poetry run python manage.py makemigrations
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
docker-compose -f test-services-docker-compose.yaml run --rm django-q2 poetry run python manage.py migrate
|
||||||
|
|
||||||
createsuperuser:
|
createsuperuser:
|
||||||
docker compose -f web-docker-compose.yaml run --rm web python manage.py createsuperuser
|
docker compose -f web-docker-compose.yaml run --rm web python manage.py createsuperuser
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.2.7 on 2024-03-05 17:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("django_q", "0017_task_cluster_alter"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="task",
|
||||||
|
index=models.Index(
|
||||||
|
condition=models.Q(("success", True)),
|
||||||
|
fields=["group", "name", "func"],
|
||||||
|
name="success_index",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -5,6 +5,7 @@ from keyword import iskeyword
|
|||||||
from django import get_version
|
from django import get_version
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.db.models import Q
|
||||||
from django.template.defaultfilters import truncatechars
|
from django.template.defaultfilters import truncatechars
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -111,6 +112,13 @@ class Task(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = "django_q"
|
app_label = "django_q"
|
||||||
ordering = ["-stopped"]
|
ordering = ["-stopped"]
|
||||||
|
indexes = [
|
||||||
|
models.Index(
|
||||||
|
name="success_index",
|
||||||
|
fields=["group", "name", "func"],
|
||||||
|
condition=Q(success=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class SuccessManager(models.Manager):
|
class SuccessManager(models.Manager):
|
||||||
|
|||||||
Reference in New Issue
Block a user