Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove jsonfield dependency and switch to enum choices
  • Loading branch information
j4mie committed Apr 5, 2021
commit ae52e3b824791700f0f88698430129e88cf5efc2
43 changes: 21 additions & 22 deletions django_dbq/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Generated by Django 3.2rc1 on 2021-04-05 14:31

from django.db import models, migrations
import jsonfield.fields
from django.db import migrations, models
import uuid

from django.db.models import UUIDField


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
Expand All @@ -18,38 +16,39 @@ class Migration(migrations.Migration):
fields=[
(
"id",
UUIDField(
serialize=False,
editable=False,
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("created", models.DateTimeField(db_index=True, auto_now_add=True)),
("created", models.DateTimeField(auto_now_add=True, db_index=True)),
("modified", models.DateTimeField(auto_now=True)),
("name", models.CharField(max_length=100)),
(
"state",
models.CharField(
db_index=True,
max_length=20,
default="NEW",
choices=[
("NEW", "NEW"),
("READY", "READY"),
("PROCESSING", "PROCESSING"),
("FAILED", "FAILED"),
("COMPLETE", "COMPLETE"),
("NEW", "New"),
("READY", "Ready"),
("PROCESSING", "Processing"),
("FAILED", "Failed"),
("COMPLETE", "Complete"),
],
db_index=True,
default="NEW",
max_length=20,
),
),
("next_task", models.CharField(max_length=100, blank=True)),
("workspace", jsonfield.fields.JSONField(null=True)),
("next_task", models.CharField(blank=True, max_length=100)),
("workspace", models.JSONField(null=True)),
(
"queue_name",
models.CharField(db_index=True, max_length=20, default="default"),
models.CharField(db_index=True, default="default", max_length=20),
),
("priority", models.SmallIntegerField(db_index=True, default=0)),
],
options={"ordering": ["-created"],},
options={"ordering": ["-priority", "created"],},
),
]
15 changes: 0 additions & 15 deletions django_dbq/migrations/0002_auto_20151016_1027.py

This file was deleted.

23 changes: 0 additions & 23 deletions django_dbq/migrations/0003_auto_20180713_1000.py

This file was deleted.

15 changes: 3 additions & 12 deletions django_dbq/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
get_failure_hook_name,
get_creation_hook_name,
)
from jsonfield import JSONField
from django.db.models import UUIDField, Count
from django.db.models import JSONField, UUIDField, Count, TextChoices
import datetime
import logging
import uuid
Expand Down Expand Up @@ -74,27 +73,19 @@ def to_process(self, queue_name):


class Job(models.Model):
class STATES:
class STATES(TextChoices):
NEW = "NEW"
READY = "READY"
PROCESSING = "PROCESSING"
FAILED = "FAILED"
COMPLETE = "COMPLETE"

STATE_CHOICES = [
(STATES.NEW, "NEW"),
(STATES.READY, "READY"),
(STATES.PROCESSING, "PROCESSING"),
(STATES.FAILED, "FAILED"),
(STATES.COMPLETE, "COMPLETE"),
]

id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created = models.DateTimeField(auto_now_add=True, db_index=True)
modified = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100)
state = models.CharField(
max_length=20, choices=STATE_CHOICES, default=STATES.NEW, db_index=True
max_length=20, choices=STATES.choices, default=STATES.NEW, db_index=True
)
next_task = models.CharField(max_length=100, blank=True)
workspace = JSONField(null=True)
Expand Down