Skip to content
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

Fix/current entities #672

Merged
merged 9 commits into from
Nov 9, 2021
10 changes: 5 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ djangorestframework-recaptcha = "~=0.2.0"
djangogrpcframework = "~=0.2.1"
grpcio = "~=1.39.0"
grpcio-tools = "~=1.39.0"
django-elasticsearch-dsl= "~=7.2.0"
django-elasticsearch-dsl-drf= "~=0.22.1"
elasticsearch= "~=7.14.0"
elasticsearch-dsl= "~=7.4.0"
django-elasticsearch-dsl = "~=7.2.0"
django-elasticsearch-dsl-drf = "~=0.22.1"
elasticsearch = "~=7.14.0"
elasticsearch-dsl = "~=7.4.0"
psycopg2-binary = "~=2.9.1"
weni-protobuffers = "~=1.2.1"

[dev-packages]
"flake8" = "~=4.0.0"
flake8 = "~=4.0.0"
requests-mock = "~=1.8.0"
coverage = "~=5.5"
ipython = "*"
Expand Down
5 changes: 2 additions & 3 deletions bothub/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,6 @@ def get_migration_types(cls):
return TYPES

def current_entities(self, queryset=None, version_default=True):
version_default = version_default or True
return self.entities.filter(
value__in=self.repository.examples(
queryset=queryset, version_default=version_default
Expand All @@ -933,7 +932,7 @@ def current_entities(self, queryset=None, version_default=True):
.distinct()
)

def entities_list(self, queryset=None, version_default=None): # pragma: no cover
def entities_list(self, queryset=None, version_default=True): # pragma: no cover
return (
self.current_entities(queryset=queryset, version_default=version_default)
.values_list("value", flat=True)
Expand All @@ -948,7 +947,7 @@ def current_groups(self):
def groups_list(self):
return self.current_groups.values_list("value", flat=True).distinct()

def other_entities(self, queryset=None, version_default=None):
def other_entities(self, queryset=None, version_default=True):
return self.current_entities(
queryset=queryset, version_default=version_default
).filter(group__isnull=True)
Expand Down
18 changes: 0 additions & 18 deletions bothub/common/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,3 @@ def handle_save(self, sender, instance, **kwargs):
"es_handle_save", args=[instance.pk, app_label, model_name]
)
)

def handle_pre_delete(self, sender, instance, **kwargs):
app_label = instance._meta.app_label
model_name = instance._meta.model_name
model = instance._meta.concrete_model
if model in registry._models or model in registry._related_models:
celery_app.send_task(
"es_handle_pre_delete", args=[instance.pk, app_label, model_name]
)

def handle_delete(self, sender, instance, **kwargs):
app_label = instance._meta.app_label
model_name = instance._meta.model_name
model = instance._meta.concrete_model
if model in registry._models or model in registry._related_models:
celery_app.send_task(
"es_handle_delete", args=[instance.pk, app_label, model_name]
)
14 changes: 0 additions & 14 deletions bothub/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ def handle_save(pk, app_label, model_name):
registry.update_related(instance)


@app.task(name="es_handle_pre_delete")
def handle_pre_delete(pk, app_label, model_name):
sender = apps.get_model(app_label, model_name)
instance = sender.objects.get(pk=pk)
registry.delete_related(instance)


@app.task(name="es_handle_delete")
def handle_delete(pk, app_label, model_name):
sender = apps.get_model(app_label, model_name)
instance = sender.objects.get(pk=pk)
registry.delete(instance, raise_on_error=False)


@app.task()
def trainings_check_task():
trainers = RepositoryQueueTask.objects.filter(
Expand Down