Features: 1) Add support for defaults in get_or_create for auto_resolver_helper; 2) Modularize Sentry ignore_errors configuration with a dedicated variable;
Fixes: None; Extra: 1) Minor code refactor to streamline `ignore_errors` handling in Sentry setup;
This commit is contained in:
parent
78db5e1f96
commit
37c0867ab7
2 changed files with 13 additions and 10 deletions
2
core/vendors/__init__.py
vendored
2
core/vendors/__init__.py
vendored
|
|
@ -102,7 +102,7 @@ class AbstractVendor:
|
||||||
def auto_resolver_helper(model: type[Brand] | type[Category], resolving_name: str):
|
def auto_resolver_helper(model: type[Brand] | type[Category], resolving_name: str):
|
||||||
queryset = model.objects.filter(name=resolving_name)
|
queryset = model.objects.filter(name=resolving_name)
|
||||||
if not queryset.exists():
|
if not queryset.exists():
|
||||||
return model.objects.create(name=resolving_name, is_active=False)
|
return model.objects.get_or_create(name=resolving_name, defaults={"is_active": False})
|
||||||
elif queryset.filter(is_active=True).count() > 1:
|
elif queryset.filter(is_active=True).count() > 1:
|
||||||
queryset = queryset.filter(is_active=True)
|
queryset = queryset.filter(is_active=True)
|
||||||
elif queryset.filter(is_active=False).count() > 1:
|
elif queryset.filter(is_active=False).count() > 1:
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,17 @@ if getenv("SENTRY_DSN"):
|
||||||
from sentry_sdk.integrations.logging import LoggingIntegration
|
from sentry_sdk.integrations.logging import LoggingIntegration
|
||||||
from sentry_sdk.integrations.redis import RedisIntegration
|
from sentry_sdk.integrations.redis import RedisIntegration
|
||||||
|
|
||||||
|
ignore_errors = [
|
||||||
|
"flower.views.error.NotFoundErrorHandler",
|
||||||
|
"django.http.response.Http404",
|
||||||
|
"billiard.exceptions.SoftTimeLimitExceeded",
|
||||||
|
"billiard.exceptions.WorkerLostError",
|
||||||
|
"core.models.Product.DoesNotExist",
|
||||||
|
"core.models.Category.DoesNotExist",
|
||||||
|
"core.models.Brand.DoesNotExist",
|
||||||
|
"blog.models.Post.DoesNotExist",
|
||||||
|
]
|
||||||
|
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn=getenv("SENTRY_DSN"),
|
dsn=getenv("SENTRY_DSN"),
|
||||||
traces_sample_rate=1.0 if DEBUG else 0.2,
|
traces_sample_rate=1.0 if DEBUG else 0.2,
|
||||||
|
|
@ -305,15 +316,7 @@ if getenv("SENTRY_DSN"):
|
||||||
environment="dev" if DEBUG else "prod",
|
environment="dev" if DEBUG else "prod",
|
||||||
debug=DEBUG,
|
debug=DEBUG,
|
||||||
release=f"evibes@{EVIBES_VERSION}",
|
release=f"evibes@{EVIBES_VERSION}",
|
||||||
ignore_errors=[
|
ignore_errors=ignore_errors,
|
||||||
"flower.views.error.NotFoundErrorHandler",
|
|
||||||
"django.http.response.Http404",
|
|
||||||
"billiard.exceptions.SoftTimeLimitExceeded",
|
|
||||||
"core.models.Product.DoesNotExist",
|
|
||||||
"core.models.Category.DoesNotExist",
|
|
||||||
"core.models.Brand.DoesNotExist",
|
|
||||||
"blog.models.Post.DoesNotExist",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SESSION_COOKIE_HTTPONLY = True
|
SESSION_COOKIE_HTTPONLY = True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue