commit
205fc06aaa
7 changed files with 74 additions and 14 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
|
@ -5,12 +5,26 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v1.1.11 (2023-01-03)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix error when schedule was not able to load
|
||||
- Minor fixes
|
||||
|
||||
## v1.1.10 (2023-01-03)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Minor fixes
|
||||
|
||||
## v1.1.9 (2023-01-03)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Alert group query optimization
|
||||
- Update RBAC scopes
|
||||
- Fix error when schedule was not able to load
|
||||
- Minor bug fixes
|
||||
|
||||
## v1.1.8 (2022-12-13)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ RUN apt-get update && apt-get install -y \
|
|||
python3-dev \
|
||||
gcc \
|
||||
libmariadb-dev \
|
||||
libpq-dev \
|
||||
netcat \
|
||||
curl \
|
||||
bash
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.text import Truncator
|
||||
|
||||
from apps.alerts.incident_appearance.renderers.base_renderer import AlertBaseRenderer, AlertGroupBaseRenderer
|
||||
from apps.alerts.incident_appearance.templaters import AlertSlackTemplater
|
||||
|
|
@ -18,26 +19,31 @@ class AlertSlackRenderer(AlertBaseRenderer):
|
|||
return AlertSlackTemplater
|
||||
|
||||
def render_alert_blocks(self):
|
||||
BLOCK_SECTION_TEXT_MAX_SIZE = 2800
|
||||
blocks = []
|
||||
|
||||
title = Truncator(str_or_backup(self.templated_alert.title, "Alert"))
|
||||
blocks.append(
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": str_or_backup(self.templated_alert.title, "Alert"),
|
||||
"text": title.chars(BLOCK_SECTION_TEXT_MAX_SIZE),
|
||||
},
|
||||
}
|
||||
)
|
||||
if is_string_with_visible_characters(self.templated_alert.message):
|
||||
message = self.templated_alert.message
|
||||
BLOCK_SECTION_TEXT_MAX_SIZE = 2800
|
||||
if len(message) > BLOCK_SECTION_TEXT_MAX_SIZE:
|
||||
message = (
|
||||
message[: BLOCK_SECTION_TEXT_MAX_SIZE - 3] + "... Message has been trimmed. "
|
||||
"Check the whole content in Web"
|
||||
)
|
||||
blocks.append({"type": "section", "text": {"type": "mrkdwn", "text": message}})
|
||||
message = Truncator(self.templated_alert.message)
|
||||
truncate_wording = "... Message has been trimmed. Check the whole content in Web"
|
||||
blocks.append(
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": message.chars(BLOCK_SECTION_TEXT_MAX_SIZE, truncate=truncate_wording),
|
||||
},
|
||||
}
|
||||
)
|
||||
return blocks
|
||||
|
||||
def render_alert_attachments(self):
|
||||
|
|
|
|||
|
|
@ -1113,7 +1113,7 @@ def test_merging_same_shift_events(
|
|||
|
||||
data = {
|
||||
"start": start_date + timezone.timedelta(hours=10),
|
||||
"rotation_start": start_date,
|
||||
"rotation_start": start_date + timezone.timedelta(hours=10),
|
||||
"duration": timezone.timedelta(hours=2),
|
||||
"priority_level": 1,
|
||||
"frequency": CustomOnCallShift.FREQUENCY_DAILY,
|
||||
|
|
|
|||
|
|
@ -322,8 +322,10 @@ class CustomOnCallShift(models.Model):
|
|||
if all_rotations_checked:
|
||||
break
|
||||
|
||||
# number of weeks used to cover all combinations
|
||||
week_interval = ((last_start - orig_start).days // 7) or 1
|
||||
week_interval = 1
|
||||
if orig_start and last_start:
|
||||
# number of weeks used to cover all combinations
|
||||
week_interval = ((last_start - orig_start).days // 7) or 1
|
||||
counter = 1
|
||||
for ((user_group_id, day, _), start) in zip(combinations, starting_dates):
|
||||
users = users_queue[user_group_id]
|
||||
|
|
@ -367,7 +369,7 @@ class CustomOnCallShift(models.Model):
|
|||
start = self.get_rotation_date(event_ical)
|
||||
|
||||
# Make sure we respect the selected days if any when defining start date
|
||||
if self.frequency is not None and self.by_day:
|
||||
if self.frequency is not None and self.by_day and start is not None:
|
||||
start_day = CustomOnCallShift.ICAL_WEEKDAY_MAP[start.weekday()]
|
||||
if start_day not in self.by_day:
|
||||
expected_start_day = min(CustomOnCallShift.ICAL_WEEKDAY_REVERSE_MAP[d] for d in self.by_day)
|
||||
|
|
|
|||
|
|
@ -1430,3 +1430,40 @@ def test_rolling_users_shift_convert_to_ical(
|
|||
|
||||
assert on_call_shift.event_interval == len(rolling_users) * data["interval"]
|
||||
assert expected_rrule in ical_data
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rolling_users_event_daily_by_day_start_none_convert_to_ical(
|
||||
make_organization_and_user, make_user_for_organization, make_on_call_shift, make_schedule
|
||||
):
|
||||
organization, user_1 = make_organization_and_user()
|
||||
|
||||
schedule = make_schedule(organization, schedule_class=OnCallScheduleWeb)
|
||||
now = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
today_weekday = now.weekday()
|
||||
delta_days = (0 - today_weekday) % 7 + (7 if today_weekday == 0 else 0)
|
||||
next_week_monday = now + timezone.timedelta(days=delta_days)
|
||||
|
||||
# MO
|
||||
weekdays = [0]
|
||||
by_day = [CustomOnCallShift.ICAL_WEEKDAY_MAP[day] for day in weekdays]
|
||||
data = {
|
||||
"priority_level": 1,
|
||||
"start": now + timezone.timedelta(hours=12),
|
||||
"rotation_start": next_week_monday,
|
||||
"duration": timezone.timedelta(seconds=3600),
|
||||
"frequency": CustomOnCallShift.FREQUENCY_DAILY,
|
||||
"interval": 1,
|
||||
"by_day": by_day,
|
||||
"schedule": schedule,
|
||||
"until": now,
|
||||
}
|
||||
rolling_users = [[user_1]]
|
||||
on_call_shift = make_on_call_shift(
|
||||
organization=organization, shift_type=CustomOnCallShift.TYPE_ROLLING_USERS_EVENT, **data
|
||||
)
|
||||
on_call_shift.add_rolling_users(rolling_users)
|
||||
|
||||
ical_data = on_call_shift.convert_to_ical()
|
||||
# empty result since there is no event in the defined time range
|
||||
assert ical_data == ""
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ https://github.com/grafana/fcm-django/archive/refs/tags/v1.0.12r1.tar.gz
|
|||
django-mirage-field==1.3.0
|
||||
django-mysql==4.6.0
|
||||
PyMySQL==1.0.2
|
||||
psycopg2-binary==2.9.3
|
||||
psycopg2==2.9.3
|
||||
emoji==1.7.0
|
||||
regex==2021.11.2
|
||||
psutil==5.9.4
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue