-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: ROOT-45: Filter by annotator prototype #7783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 18 commits
b4dbb77
b0fcde4
e3ff613
21be28f
57e79b4
ae7a9a7
035677f
ba8e2f7
8abe888
91331c0
2b47439
45230c6
cea1fe1
fccf130
89e09b7
50dda51
a43ab3d
30c3b2d
0918f2a
8804d78
1b11cd2
c781a49
f34ed29
addbecd
7fff391
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 5.1.10 on 2025-06-17 18:27 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("data_manager", "0012_alter_view_user"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="filter", | ||
name="parent", | ||
field=models.ForeignKey( | ||
blank=True, | ||
help_text="Optional parent filter to create one-level hierarchy (child filters are AND-merged with parent)", | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="children", | ||
to="data_manager.filter", | ||
db_index=False, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="filter", | ||
name="index", | ||
field=models.IntegerField( | ||
blank=True, | ||
default=None, | ||
help_text="Display order among root filters only", | ||
null=True, | ||
verbose_name="index", | ||
), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -86,7 +86,25 @@ class FilterGroup(models.Model): | |||
|
||||
|
||||
class Filter(models.Model): | ||||
index = models.IntegerField(_('index'), default=0, help_text='To keep filter order') | ||||
# Optional reference to a parent filter. We only allow **one** level of nesting. | ||||
parent = models.ForeignKey( | ||||
'self', | ||||
on_delete=models.CASCADE, | ||||
related_name='children', | ||||
null=True, | ||||
blank=True, | ||||
db_index=False, | ||||
help_text='Optional parent filter to create one-level hierarchy (child filters are AND-merged with parent)', | ||||
) | ||||
|
||||
# `index` is now only meaningful for **root** filters (parent is NULL) | ||||
index = models.IntegerField( | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way we could name this field to make it clearer what it really represents? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field isn't new, renaming it would have increased change surface area, but yes it's possible. Could do it in a separate chore PR |
||||
_('index'), | ||||
null=True, | ||||
blank=True, | ||||
default=None, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit - as long as we are making other changes, we can remove this
Suggested change
|
||||
help_text='Display order among root filters only', | ||||
) | ||||
column = models.CharField(_('column'), max_length=1024, help_text='Field name') | ||||
type = models.CharField(_('type'), max_length=1024, help_text='Field type') | ||||
operator = models.CharField(_('operator'), max_length=1024, help_text='Filter operator') | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to satisfy the linter? While it's strictly necessary, I always like to have indices on FKs to support flexible querying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - I tried adding an index in a concurrent migration, but wasn't able to do it in a way that passed the migration linter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to suppress the migration linter like so:
label-studio/label_studio/users/migrations/0010_userproducttour.py
Line 16 in 4a1582d