Skip to content

Commit d4d44e2

Browse files
committed
Generating filetype and count to be EnumFields
1 parent 7c5481b commit d4d44e2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

jwql/website/apps/jwql/monitor_models/common.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ class Meta:
177177
# Feel free to rename the models, but don't rename db_table values or field names.
178178
from django.db import models
179179
from django.contrib.postgres.fields import ArrayField
180+
from django_enum import EnumField
181+
from enum import Enum
180182

181-
from jwql.utils.constants import DEFAULT_MODEL_CHARFIELD, MAX_LEN_FILTER
183+
from jwql.utils.constants import DEFAULT_MODEL_CHARFIELD, MAX_LEN_FILTER, FILE_SUFFIX_TYPES
184+
185+
FILE_SUFFIX_CLASS = Enum('FILE_SUFFIX_CLASS', FILE_SUFFIX_TYPES)
182186

183187

184188
class Monitor(models.Model):
@@ -244,9 +248,8 @@ class Meta:
244248

245249
class FilesystemInstrument(models.Model):
246250
date = models.DateTimeField()
247-
instrument = models.TextField() # This field type is a guess.
248-
filetype = models.TextField() # This field type is a guess.
249-
count = models.IntegerField()
251+
filetype = EnumField(FILE_SUFFIX_CLASS) # This field type is a guess.
252+
count = EnumField(FILE_SUFFIX_CLASS)
250253
size = models.FloatField()
251254

252255
class Meta:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies = [
2727
"celery>=5.3.6,<6",
2828
"crds>=11.17.19,<12",
2929
"django>=5.0.3,<6",
30+
"django-enum>=2.0.2,<3",
3031
"gunicorn>=22.0.0,<23.0.0",
3132
"inflection>=0.5.1,<0.6",
3233
"jsonschema>=4.21.1,<5",

0 commit comments

Comments
 (0)