Commit graph

1569 commits

Author SHA1 Message Date
Joey Orlando
d5b43b0439
minor improvements for check_escalation_finished celery task (#2554)
# What this PR does

This PR adds some enhancements to the `check_escalation_finished` celery
task. It short-circuits auditing of an alert group if it does not have
an escalation chain associated with it. In
`EscalationSnapshotMixin.start_escalation_if_needed`
we will not set `raw_escalation_snapshot`
([here](https://github.com/grafana/oncall/blob/dev/engine/apps/alerts/escalation_snapshot/escalation_snapshot_mixin.py#L262))
in this case:
```python3
def start_escalation_if_needed(self, countdown=START_ESCALATION_DELAY, eta=None):
        """
        :type self:AlertGroup
        """
        AlertGroup = apps.get_model("alerts", "AlertGroup")

        is_on_maintenace_or_debug_mode = self.channel.maintenance_mode is not None

        if (
            self.is_restricted
            or is_on_maintenace_or_debug_mode
            or self.pause_escalation
            or not self.escalation_chain_exists <-- here
        ):
            logger.debug(
                f"Not escalating alert group w/ pk: {self.pk}\n"
                f"is_restricted: {self.is_restricted}\n"
                f"is_on_maintenace_or_debug_mode: {is_on_maintenace_or_debug_mode}\n"
                f"pause_escalation: {self.pause_escalation}\n"
                f"escalation_chain_exists: {self.escalation_chain_exists}"
            )
            return

        logger.debug(f"Start escalation for alert group with pk: {self.pk}")

        # take raw escalation snapshot from db if escalation is paused
        raw_escalation_snapshot = (
            self.build_raw_escalation_snapshot() if not self.pause_escalation else self.raw_escalation_snapshot
        )
        task_id = celery_uuid()

        AlertGroup.all_objects.filter(pk=self.pk,).update(
            active_escalation_id=task_id,
            is_escalation_finished=False,
            raw_escalation_snapshot=raw_escalation_snapshot,
        )
```

`EscalationSnapshotMixin.escalation_chain_exists` is as such:
```python3
@property
    def escalation_chain_exists(self) -> bool:
        if self.pause_escalation:
            return False
        elif not self.channel_filter:
            return False
        return self.channel_filter.escalation_chain is not None
```

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required) (N/A)
2023-07-17 14:04:53 +00:00
Vadim Stepanov
69bafb61f1
Direct paging improvements (#2537)
# What this PR does

- Deprecates `/oncall` Slack command in favour of `/esalate` (direct
paging) + fixes a regression bug in both commands
- Unifies direct paging UX across Slack & Web UI (or at least makes an
attempt to make things more similar). Kudos to @iskhakov for all the
great work on this recently!
- A bunch of minor changes that hopefully make direct paging more usable
- TODO: documentation updates will be added in a separate PR

## Screenshots

### No issues scenario

Slack:

<img width="522" alt="Screenshot 2023-07-14 at 23 53 11"
src="https://github.com/grafana/oncall/assets/20116910/ec15a18f-d817-4177-b1f2-6b89d79bb361">


Web UI: 

<img width="1172" alt="Screenshot 2023-07-14 at 23 52 25"
src="https://github.com/grafana/oncall/assets/20116910/813f967c-2fdd-4868-9287-487dbfa7cea6">


### Not configured scenario

Slack:

<img width="519" alt="Screenshot 2023-07-14 at 23 45 22"
src="https://github.com/grafana/oncall/assets/20116910/932fa05c-81ea-42ca-be80-41b05f767d3e">

Web UI:

<img width="1172" alt="Screenshot 2023-07-14 at 23 47 31"
src="https://github.com/grafana/oncall/assets/20116910/6bcb07e4-2e50-4120-9fac-be8b0277e181">

### `/oncall` deprecation warning

<img width="521" alt="Screenshot 2023-07-17 at 10 31 56"
src="https://github.com/grafana/oncall/assets/20116910/4ff28337-1693-4af0-81d9-9eda90099c1b">


## Which issue(s) this PR fixes

https://github.com/grafana/oncall/issues/2442

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-17 14:21:56 +01:00
Andrey Oleynik
8644883883
set default phone provider (#2523)
# What this PR does

Sets a default value for the PHONE_PROVIDER setting and replaces the
value of PHONE_PROVIDER with this default value if it is not valid.

## Which issue(s) this PR fixes

- [#2520](https://github.com/grafana/oncall/issues/2520)
- [#2323](https://github.com/grafana/oncall/issues/2323)

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-07-17 13:04:55 +00:00
Joey Orlando
3181e5de82
fix mypy errors 2023-07-17 13:10:57 +02:00
Ildar Iskhakov
8367a1ed4c
Polish user settings and warnings (#2425)
# What this PR does

* users table: added warnings: No default notifications set, No
important notifications set
* users table: removed warnings when messenger is not configured (e.g.
telegram channels are not connected -> no need to show telegram warning
in users table)
* users table: moved current user to first place
* user profile: cleaned up and added hints to notification channel
connectors
* user profile: cleaned up and added hints to calendar sync
* chatops-slack: cleaned up and added hints to slack settings

fixes https://github.com/grafana/oncall/issues/2418

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-17 18:34:58 +08:00
Joey Orlando
63ac0972c5
remove deprecated heartbeat_heartbeat table/model (#2534)
# What this PR does

- Remove `heartbeat_heartbeat` table. This model/table does not seems to
be deprecated/used anywhere (no data in this in production/staging; see
more comments in the code about this).
2023-07-17 01:38:04 -04:00
Innokentii Konstantinov
aa4edad4a7
Remove INTEGRATIONS_TO_REVERSE_URL_MAP (#2533)
This PR is a step for migrating to AlertManager v2. I want to simplify
config thing a little to be able to move forward.
In INTEGRATIONS_TO_REVERSE_URL_MAP key equal value and in all cases we
just don't need it.

Public API is different, since I need this mapping for migration to
AlertManager v2 to provide backward-compatibility. It will be done in
next PRs.
2023-07-17 04:43:24 +00:00
Michael Derynck
a40e38300e
Fix authorization header masked (#2541)
# What this PR does
Fix authorization header was being masked in the requests instead of
only in logs

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-14 22:52:41 +00:00
Joey Orlando
767c5352fa
augment API response pagination attributes (#2471)
# What this PR does

This PR:
- adds a few attributes to paginated API responses
- removes channel filter "send demo alert" internal API endpoint + tests
(this endpoint was marked as deprecated + not consumed by the web UI)

With the new paginated API response schema, the web UI will no longer
need to:
- hardcode `ITEMS_PER_PAGE` for each table
- manually calculate total number of pages

(these two things ☝️ will be done in
https://github.com/grafana/oncall/issues/2476)

For `GET /api/internal/v1/alertgroups` the response will now look like
this:
```diff
{
    "next": <url> | None,
    "previous": <url> | None,
    "results": [],
++  "page_size": <int>
}
```

For all other paginated API responses, the response will now look like:
```diff
{
    "count": <int>,
    "next": <url> | None,
    "previous": <url> | None,
    "results": [],
++  "page_size": <int>,
++  "current_page_number": <int>,
++  "total_pages": <int>
}
```

## TODO
- [x] update public API docs to include these new attributes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-14 11:19:40 -04:00
Joey Orlando
681087117c
remove deprecated gitops views (#2530)
# What this PR does

I don't see any traffic to these endpoint URLs over the past week. The
terraform "renderers" in `engine/apps/alerts/terraform_renderer` make a
lot of references to amixr, making think these are legacy, and can be
removed.

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated (N/A)
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required) (N/A)
2023-07-14 05:13:52 -04:00
Michael Derynck
aef162652e
Fix migration for long names and do not include deleted (#2528) 2023-07-13 16:32:30 -06:00
Michael Derynck
961a9e5349
Webhooks 2 Release (#1830)
- Enables new webhooks functionality.
- Database migration will automatically convert existing webhooks to new
ones. Note: Converted webhooks are considered "legacy" they will
continue to work as part of your escalation chain but will no longer be
editable. To make changes use the `Make a copy` action and edit that
one, after you can delete your legacy webhook. Remember to connect your
escalation chain with your newly copied webhook!

---------

Co-authored-by: Maxim <maxim.mordasov@grafana.com>
2023-07-13 13:53:06 -06:00
Joey Orlando
77f6dedce5
add index on started_at column in alert groups (#2516)
# What this PR does

Adds an index on the `started_at` column in the `alerts_alertgroup`
table. For the alert groups query used by the
`check_escalation_finished_task`, this resulted in a huge performance
boost, taking the query time from 89mins to 4secs (on our largest
production dataset).

## Which issue(s) this PR fixes

closes #724
closes https://github.com/grafana/oncall-private/issues/1713

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-13 05:22:59 -04:00
Ildar Iskhakov
0b28815d46
Unhide direct paging integration (#2483)
# What this PR does
Fixes https://github.com/grafana/oncall/issues/2442



https://github.com/grafana/oncall/assets/2262529/08bb8e5f-acc6-4f2d-9e38-717c9f37e3da





## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-13 13:41:31 +08:00
Joey Orlando
d24dc4b630
remove organization maintenance mode + fix integration maintenance mode (#2511) 2023-07-12 16:41:44 -04:00
Joey Orlando
385e1377d6
remove deprecated backend code (#2502)
# What this PR does

See more details comments alongside the code.

Regarding frontend changes, the main changes in this PR are to remove
unused fields on the `Team` interface + unused methods on the `Team`
model.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required) (N/A)
2023-07-12 02:07:45 -04:00
Michael Derynck
fd9460f6bc
Webhooks 2 template editor fixes (#2504)
- Fix Integrations drop down loading
- Fix template editor preview for newly created webhooks

---------

Co-authored-by: Maxim <maxim.mordasov@grafana.com>
2023-07-11 14:01:38 -06:00
Rares Mardare
5ebf437283
Rares/add template editor to webhooks (#2455)
# What this PR does

Bring new Jinja editor to webhooks

## Which issue(s) this PR fixes

https://github.com/grafana/oncall/issues/2344

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Maxim <maxim.mordasov@grafana.com>
Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
2023-07-11 18:03:34 +00:00
Vadim Stepanov
b2fc9635bf
Bring back /oncall Slack command (#2500)
Reverts grafana/oncall#2499

`/oncall` command was removed by mistake.
2023-07-11 14:43:06 +01:00
Vadim Stepanov
028cb7d7fc
Remove ability to create alert groups via Slack message shortcut (#2499)
# What this PR does

Removes an ability to create alert groups via Slack message shortcut
(three dots menu near to a message), since this feature is outdated and
not documented anywhere.

## Which issue(s) this PR fixes

Related to https://github.com/grafana/oncall/issues/2442

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-11 13:09:02 +00:00
Yulya Artyukhina
195181f571
Exclude schedules from deleted organizations from notification list (#2493)
# What this PR does
On notifying about shifts change in slack we don't check whether
organization was deleted. This PR excludes schedules from deleted
organizations from shift notification list

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-11 10:32:10 +00:00
Ben Sully
bb53b8fc4f
Incident API: include 'title' and permalinks in serializer (#2480)
Grafana Incident is attempting to load the title and Slack thread link
from attached OnCall alert groups, but those fields aren't being exposed
by the OnCall API for Grafana Incident. This commit changes that and
exposes those fields.
2023-07-11 07:53:39 +00:00
Joey Orlando
182f18de2c
fix parsing of grafana feature flags that're enabled via the feature_toggles.enabled syntax (#2477)
# What this PR does

Grafana provides two methods for enabling feature flags:
- `feature_toggles.enabled`
- `feature_toggles.<name_of_feature_flag>`

For example, to enable `accessControlOnCall` you could either do:
```json
{
  "feature_toggles": {
    "enabled": "accessControlOnCall,someOtherCoolFeatureFlag"
  }
}
```

or:
```json
{
  "feature_toggles": {
    "accessControlOnCall": true,
    "someOtherCoolFeatureFlag": true
  }
}
```

In method 1, if they're multiple feature flags present, they are _comma
separated, not space separated_. This PR fixes this parsing issue.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-10 04:59:15 -04:00
Joey Orlando
1988ac1068
fix pagination next and previous links for schedules and integrations GET endpoints (#2467)
# Which issue(s) this PR fixes

closes https://github.com/grafana/oncall/issues/2463

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-07 12:24:21 -04:00
Joey Orlando
1801cecaff
add user (full) avatar to schedule filter events internal API endpoint (#2459)
# What this PR does

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-06 15:43:04 -04:00
Joey Orlando
ce3996c5ff
modify FCMDevice model to be a proxy model so that we dont create a table for it 2023-07-05 18:38:38 +02:00
Joey Orlando
6cb871c585
add missing database migrations 2023-07-05 18:27:56 +02:00
Joey Orlando
425ffbb740
address mobile device push notification delivery issue when user had > 1 registered device (#2421)
# What this PR does

Address issue where if the user had multiple registered devices w/ FCM,
doing django queries like `.first()` could potentially pick the wrong
device. Do this in two ways:
1. set the `DELETE_INACTIVE_DEVICES` `fcm_django` setting to `True`.
According to the
[docs](20e275618b/README.rst (L127-L130)),
this works as follows:

> devices to which notifications cannot be sent, are deleted upon
receiving error response from FCM
2. Customizing the `FCMDevice` model provided by `fcm_django`. Add a new
method, `get_active_device_for_user`, so that we can centralize the
logic for this rather than duplicating
`FCMDevice.objects.filter(user=user).first()`

## Which issue(s) this PR fixes

https://raintank-corp.slack.com/archives/C0229FD3CE9/p1688461915752119

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-05 15:14:46 +00:00
Joey Orlando
01b1be85af
fix mypy return errors (#2408)
# What this PR does

Fix the following `return` `mypy` errors (related to #2392):

```bash
❯ mypy .
apps/telegram/updates/update_manager.py:36: error: Missing return statement  [return]
apps/slack/scenarios/step_mixins.py:109: error: Missing return statement  [return]
apps/mobile_app/tasks.py:368: error: Missing return statement  [return]
apps/telegram/updates/update_handlers/button_press.py:48: error: Missing return statement  [return]
apps/twilioapp/phone_provider.py:28: error: Missing return statement  [return]
apps/twilioapp/phone_provider.py:61: error: Missing return statement  [return]
Found 6 errors in 5 files (checked 595 source files)
```

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-05 11:36:59 +00:00
Ildar Iskhakov
5cc06b7041
Remove url from sms notification, change format (#2317)
# What this PR does
Remove link from sms notification to avoid difficulties with different
countries anti-spam regulations


## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-07-05 16:32:54 +08:00
Innokentii Konstantinov
fe5b6516f0 Update CHANGELOG.md 2023-07-05 14:30:51 +08:00
Yulya Artyukhina
4f6cfcca28
Add organization moved exception to mobile app auth (#2422)
# What this PR does

Add organization moved exception to mobile app auth to redirect requests
to correct region

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-05 06:11:56 +00:00
Andrey Oleynik
aeb35009be
add zvonok integration (#2339)
Added integration with [zvonok.com](https://zvonok.com) service.

Features:
- Phone number validation
- Test calls
- Selection of pre-recorded audio
- Making calls
- Processing call status
- Acknowledgment alert group (optional)

To process the call status, it is required to add a postback with the
GET method on the side of the zvonok.com service with the following
format ([more info
here](https://zvonok.com/ru-ru/guide/guide_postback/)):

```${ONCALL_BASE_URL}/zvonok/call_status_events?campaign_id={ct_campaign_id}&call_id={ct_call_id}&status={ct_status}&user_choice={ct_user_choice}```

The names of the transmitted parameters can be redefined through environment variables.

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
2023-07-05 05:55:53 +00:00
Innokentii Konstantinov
44d0252ef1
Remove test push dynamic setting (#2416) 2023-07-04 15:01:30 +08:00
Vadim Stepanov
44e1bef250
Add full avatar URL for on-call users in schedule internal API (#2414)
# What this PR does

Adds full avatar URL for on-call users in schedule internal API
(`avatar_full`).

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-30 14:45:40 +01:00
Vadim Stepanov
aa2bb81519
Simplify SlackEventApiEndpointView methods (#2384)
# What this PR does

Simplifies `_get_organization_from_payload` and
`_get_slack_team_identity_from_payload` methods on
`SlackEventApiEndpointView`, so it's (hopefully) easier to grasp.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-29 16:23:33 +00:00
Yulya Artyukhina
04047c6ebe
Resolution notes endpoint docs (#2404)
# What this PR does
- Add docs for `/resolution_notes` public api endpoint
- Fix resolution notes order to show notes for the newest alert group on
top

## Which issue(s) this PR fixes
https://github.com/grafana/oncall/issues/222

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-29 14:08:21 +00:00
Joey Orlando
cc20c9dfdd
re-enable mypy GitHub Actions CI job (#2390)
# What this PR does

```bash
❯ mypy .
Success: no issues found in 595 source files
```

- re-enable the mypy CI check
- fixes all `django-manager-missing` mypy errors
- disable all other rules currently giving mypy errors
- changing the approach here. rather than enforcing that backend
contributors fix >= 1 `mypy` error on their PR, lets simply disable all
the rules that're currently returning errors and slowly re-enable these
one at a time #2392

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated (N/A)
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required) (N/A)
2023-06-29 14:01:52 +00:00
Yulya Artyukhina
cef9e0ac79
Fix alerts order in public api (#2402)
# What this PR does
Change alerts order in `/alert` public api endpoint

## Which issue(s) this PR fixes
https://github.com/grafana/oncall/issues/1031

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-29 12:52:30 +00:00
Vadim Stepanov
3ebfd9c8b2
Remove outdated Slack functionality to create alerts (#2383)
# What this PR does

There's an outdated Slack handler that creates alerts when a file is
shared in a channel. I can't remember why it was introduced in the first
place, but I'm pretty sure that it's deprecated a long time ago, and
this feature is not documented anywhere. The PR also removes
`AlertReceiveChannel.integration_slack_channel_id` as it's no longer
used.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-29 10:09:02 +00:00
Vadim Stepanov
be4176b947
Make OrderedModel.save() respect additional arguments (#2382)
# What this PR does

Make `OrderedModel.save()` respect additional arguments (e.g. `using`)

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-28 14:53:48 +00:00
Yulya Artyukhina
f1fcb41fb4
Add "user_was_notified_of_alert_groups" metric (#2334)
This PR adds new metric for Prometheus exporter
"user_was_notified_of_alert_groups" which counts how many alert groups
user was notified of.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-06-28 08:15:19 +00:00
Joey Orlando
75028d0427
continue addressing mypy violations (#2170)
# What this PR does

See #2173 

Also, closes #2187 . All of the new files under `type_stubs/icalendar`
were autogenerated by running:

```bash
stubgen -p icalendar -o type_stubs
```

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-27 10:23:08 +00:00
Joey Orlando
f75747ac23
For "You're Going OnCall" push notifications, show shift times in the user's configured timezone, otherwise UTC (#2351)
# Which issue(s) this PR fixes

closes #2350

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-27 05:59:54 +00:00
Ildar Iskhakov
065cc9343a
Show 100000+ in stats when there are more than 100000 alert groups in the result (#1901)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-27 02:58:16 +00:00
Vadim Stepanov
1203b615c9
Fix phone call & SMS relay (#2345)
# What this PR does

Fix incorrect order of arguments for phone provider method invocations
when relaying phone calls and SMS from OSS instances.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-26 16:09:21 +00:00
Matias Bordese
f4eb2bbf2e
Remove unused prefetch_related in metrics task (#2343)
The `prefecth_related` data here is not being used later (since we are
applying filters not getting `.all`) and it is preloading all alert
groups for integrations into memory (which can be a lot).
2023-06-26 14:12:10 +00:00
Vadim Stepanov
eada4a4355
Fix duplicate orders for user notification policies (#2278)
# What this PR does

Fixes an issue when multiple user notification policies have duplicated
order values, leading to the following unexpected behaviours:
1. Not possible to rearrange notification policies that have duplicated
orders.
2. The notification system only executes the first policy from each
order group. For example, if there are policies with orders `[0, 0, 0,
0]`, only the first policy will be executed, and all others will be
skipped. So the user will see four policies in the UI, while only one of
them will be actually executed.

This PR fixes the issue by adding a unique index on `(user_id,
important, order)` for `UserNotificationPolicy` model. However, it's not
possible to add that unique index using the ordering library that we use
due to it's implementation details.
I added a new abstract Django model `OrderedModel` that's able to work
with such unique indices + under concurrent load.

Important info on this new `OrderedModel` abstract model:
- Orders are unique on the DB level
- Orders are allowed to be non-consecutive, for example order sequence
`[100, 150, 400]` is valid
- When deleting an instance, orders of other instances don't change.
This is a notable difference from the library we use. I think it's
better to only delete the instance without changing any other orders,
because it reduces the number of dependencies between instances (e.g.
Terraform drift will be much smaller this way if a policy is deleted via
the web UI).

## Which issue(s) this PR fixes

Related to https://github.com/grafana/oncall-private/issues/1680

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-21 11:13:56 +00:00
Yulya Artyukhina
af939dc83a
Optimize getting response time for alert groups (#2296)
Optimize getting response time for alert groups in calculation metrics
task

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-21 08:16:35 +00:00
Matias Bordese
89834ee232
Changed web schedule updates to sync refresh ical (#2279)
Updating a schedule using the web UI sometimes you don't get the change
immediately available (since the ical refresh is async).
Related to https://github.com/grafana/oncall/issues/1968
2023-06-20 15:01:35 +00:00