-
Notifications
You must be signed in to change notification settings - Fork 2
SLA Reminder #238
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?
SLA Reminder #238
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -549,3 +549,54 @@ def send_contact_check_submitted(check_id): | |||||
| networks=check.contact.networks.all(), | ||||||
| check=check, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| @shared_task(ignore_result=True, store_errors_even_if_ignored=True) | ||||||
| def event_sla_reminder(minutes=None): | ||||||
| """ | ||||||
| Envia un mail al team con los eventos que estan por superar el SLA. | ||||||
| """ | ||||||
|
|
||||||
| # Get the interval for the periodic task | ||||||
| if minutes is not None: | ||||||
| try: | ||||||
| minutes = int(minutes) | ||||||
| except ValueError: | ||||||
| raise TaskFailure("Minutes parameter must be an integer.") | ||||||
| timedeltavalue = timezone.timedelta(minutes=minutes) | ||||||
|
||||||
| else: | ||||||
| task = PeriodicTask.objects.filter(task="ngen.tasks.event_sla_reminder").first() | ||||||
| if task and task.interval: | ||||||
| interval = task.interval | ||||||
| period = ( | ||||||
| interval.period | ||||||
| ) # 'seconds', 'minutes', 'hours', 'minutes', 'weeks' | ||||||
|
||||||
| ) # 'seconds', 'minutes', 'hours', 'minutes', 'weeks' | |
| ) # 'seconds', 'minutes', 'hours', 'days', 'weeks' |
Copilot
AI
Nov 12, 2025
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.
The warning message says 'days' but the timedelta is created with minutes=default_value. Change line 581 to timezone.timedelta(days=default_value) or update the warning message to say 'minutes'.
| f"No interval found for the periodic task 'ngen.tasks.event_sla_reminder'. Using default value: {default_value} days." | |
| f"No interval found for the periodic task 'ngen.tasks.event_sla_reminder'. Using default value: {default_value} minutes." |
Copilot
AI
Nov 12, 2025
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.
The critical SLA filtering logic is commented out. This means the query returns ALL unattended events (case=None) regardless of their SLA status. The timedeltavalue parameter is calculated but never used. Either uncomment and fix lines 589-590, or remove the unused parameter calculation if this is intentional.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||
| {% extends 'reports/content_base.html' %} | ||||||
| {% load i18n %} | ||||||
| {% language lang %} | ||||||
|
|
||||||
| {% block content_header %} | ||||||
| <div class="content"> | ||||||
| <h4>{% translate 'Hello' %},</h4> | ||||||
| <p> | ||||||
| {% blocktranslate trimmed %} | ||||||
| Below are all your unattended events. | ||||||
| {% endblocktranslate %} | ||||||
| </p> | ||||||
| </div> | ||||||
| {% endblock %} | ||||||
|
|
||||||
| {% block content_body %} | ||||||
| <div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #ddd; border-radius: 8px;"> | ||||||
| <h5>{% translate 'Unnatended Events' %}: {{ events|length }}</h5> | ||||||
|
||||||
| <h5>{% translate 'Unnatended Events' %}: {{ events|length }}</h5> | |
| <h5>{% translate 'Unattended Events' %}: {{ events|length }}</h5> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -368,3 +368,66 @@ def get(self, request): | |||||||||||||||||
| }, | ||||||||||||||||||
| status=status.HTTP_200_OK, | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| class TaskRunView(APIView): | ||||||||||||||||||
| """ | ||||||||||||||||||
| View to trigger a specific task run manually. | ||||||||||||||||||
| """ | ||||||||||||||||||
|
|
||||||||||||||||||
| permission_classes = [permissions.IsAdminUser] | ||||||||||||||||||
| serializer_class = serializers.TaskRunSerializer | ||||||||||||||||||
|
|
||||||||||||||||||
| def post(self, request): | ||||||||||||||||||
| task_name = request.data.get("task_name") | ||||||||||||||||||
| async_run = request.data.get("async_run", True) | ||||||||||||||||||
| params = request.data.get("params", {}) | ||||||||||||||||||
|
Comment on lines
+382
to
+384
|
||||||||||||||||||
| task_name = request.data.get("task_name") | |
| async_run = request.data.get("async_run", True) | |
| params = request.data.get("params", {}) | |
| serializer = self.serializer_class(data=request.data) | |
| serializer.is_valid(raise_exception=True) | |
| task_name = serializer.validated_data.get("task_name") | |
| async_run = serializer.validated_data.get("async_run", True) | |
| params = serializer.validated_data.get("params", {}) |
Copilot
AI
Nov 12, 2025
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.
Corrected spelling of 'form' to 'from'.
| # get function form the module | |
| # get function from the module |
Copilot
AI
Nov 12, 2025
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.
Debug print statement should be removed or replaced with proper logging using logger.debug() or logger.info().
Copilot
AI
Nov 12, 2025
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.
The tasks module is not accessible as an attribute of models. This will raise an AttributeError. Import tasks directly at the top of the file with from ngen import tasks and change line 407 to task = getattr(tasks, task_name, None).
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.
The
paramsfield only accepts dictionary values that are strings due tochild=serializers.CharField(). This is too restrictive for task parameters which may need integers, booleans, lists, or nested objects. Consider usingparams = serializers.JSONField(required=False)orparams = serializers.DictField(required=False)without thechildconstraint to allow any JSON-serializable values.