Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Feat. Added Indeces for Files and Families
Browse files Browse the repository at this point in the history
  • Loading branch information
MeisterSeSe committed Oct 13, 2023
1 parent be456bb commit 1ab6a2d
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.2 on 2023-10-12 10:44

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core_analysis', '0018_alter_dockerprocess_resources'),
]

operations = [
migrations.RemoveField(
model_name='dockerprocess',
name='file_to_analyse',
),
migrations.RemoveField(
model_name='dockerprocess',
name='owner',
),
migrations.DeleteModel(
name='Analysis',
),
migrations.DeleteModel(
name='DockerProcess',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.2 on 2023-10-12 10:44

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core_fileupload', '0011_analysisresult'),
]

operations = [
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['owner', 'confirmation_token'], name='core_fileup_owner_i_4178bf_idx'),
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['confirmation_token'], name='core_fileup_confirm_22c787_idx'),
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['family', 'version', 'is_confirmed'], name='core_fileup_family__df0347_idx'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 4.2.2 on 2023-10-12 10:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core_fileupload', '0012_file_core_fileup_owner_i_4178bf_idx_and_more'),
]

operations = [
migrations.AddIndex(
model_name='family',
index=models.Index(fields=['owner'], name='core_fileup_owner_i_4e6325_idx'),
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['owner'], name='core_fileup_owner_i_3c733f_idx'),
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['family'], name='core_fileup_family__57b383_idx'),
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['version'], name='core_fileup_version_b47e16_idx'),
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['is_confirmed'], name='core_fileup_is_conf_ba01cb_idx'),
),
migrations.AddIndex(
model_name='license',
index=models.Index(fields=['label'], name='core_fileup_label_70ea9c_idx'),
),
migrations.AddIndex(
model_name='tag',
index=models.Index(fields=['label'], name='core_fileup_label_fa57bd_idx'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2.2 on 2023-10-12 11:02

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core_fileupload', '0013_family_core_fileup_owner_i_4e6325_idx_and_more'),
]

operations = [
migrations.RemoveIndex(
model_name='file',
name='core_fileup_owner_i_4178bf_idx',
),
migrations.RemoveIndex(
model_name='file',
name='core_fileup_confirm_22c787_idx',
),
migrations.RemoveIndex(
model_name='file',
name='core_fileup_owner_i_3c733f_idx',
),
migrations.RemoveIndex(
model_name='file',
name='core_fileup_version_b47e16_idx',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2.2 on 2023-10-13 06:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core_fileupload', '0014_remove_file_core_fileup_owner_i_4178bf_idx_and_more'),
]

operations = [
migrations.RemoveIndex(
model_name='file',
name='core_fileup_family__df0347_idx',
),
migrations.RemoveIndex(
model_name='license',
name='core_fileup_label_70ea9c_idx',
),
migrations.RemoveIndex(
model_name='tag',
name='core_fileup_label_fa57bd_idx',
),
migrations.AddIndex(
model_name='file',
index=models.Index(fields=['owner'], name='core_fileup_owner_i_3c733f_idx'),
),
]
16 changes: 14 additions & 2 deletions backend/core/fileupload/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class Family(models.Model):
class Meta:
verbose_name = "family"
verbose_name_plural = "families"
indexes = [
models.Index(fields=['owner']),
]

def __str__(self):
# do not change that
Expand Down Expand Up @@ -160,6 +163,13 @@ class File(models.Model):
slug = models.SlugField(null=True)
confirmation_token = models.CharField(default="", max_length=255)

class Meta:
indexes = [
models.Index(fields=['owner']),
models.Index(fields=['family']),
models.Index(fields=['is_confirmed']),
]

def __str__(self):
# do not change that
return f"{self.id}"
Expand All @@ -169,17 +179,19 @@ def save(self, *args, **kwargs): # new
self.slug = slugify(self.label)
return super().save(*args, **kwargs)


class Analysis(models.Model):
admin_only = models.BooleanField(default=False)
disabled = models.BooleanField(default=False)
query = models.TextField()

depends_on = models.ManyToManyField("self", symmetrical=False)


class AnalysisResult(models.Model):
triggered = models.BooleanField(default=False)
error = models.BooleanField(default=False)
result = models.JSONField(null=True)

analysis = models.ForeignKey(Analysis, on_delete=models.CASCADE)
file = models.ForeignKey(File, on_delete=models.CASCADE)

0 comments on commit 1ab6a2d

Please sign in to comment.