Commit graph

63 commits

Author SHA1 Message Date
Matias Bordese
f3f7c17f8b
fix: update missing users / empty shifts check (#5322)
Related to https://github.com/grafana/oncall-private/issues/2950

- Represent missing users in schedule events (so they are displayed in
the web UI)
- Fix schedule checks for gaps/empty shifts so they send notifications
2025-01-02 13:50:09 +00:00
Michael Derynck
c65a3c9cea
Fix for user appearing in shift rotation when they should not be (#5064)
# What this PR does
Fix calculation for interval when building ical events for schedules
with end dates and masked days. Add a test which makes it easier to test
different cases that can occur.

## Which issue(s) this PR closes

Related to https://github.com/grafana/support-escalations/issues/12388

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

---------

Co-authored-by: Matias Bordese <mbordese@gmail.com>
2024-10-03 20:04:55 +00:00
Yulya Artyukhina
16ce0136f3
Refactor gaps and empty shift checks (#3785)
Refactor gaps and empty shift checks:
- Increase checking gaps and empty shifts frequency
- Unify gaps and empty shift checks
2024-01-31 15:25:06 +01:00
Matias Bordese
c4fb620328
Upgrade to django 4.2.6 and other deps updates (#3176) 2023-10-27 18:45:00 +00:00
Joey Orlando
2576954b51
add shifts property to shift swap request response schema + finalize slack message layout (#2712)
# What this PR does

- drop `GET /api/internal/v1/shift_swaps/<id>/shifts` endpoint in favour
of adding a `shifts` property to the response schema for all shift swap
endpoints (expect `GET /api/internal/v1/shift_swaps` (ie. list all))
- Update the Slack message layout:

<img width="590" alt="Screenshot 2023-08-01 at 17 28 44"
src="https://github.com/grafana/oncall/assets/9406895/84a51614-5dd6-48ec-ae81-fef4bc32fec9">

**Note**: about the highlighted lines. This is a small issue w/ the
`ShiftSwapRequest.shifts` method. @matiasb is already helping out here 🙏

**Other stuff**
- adds some type hints related to the code I was working around with
- slightly refactor `apps.slack.utils.format_datetime_to_slack` to make
it more generic for the use case in this PR

## 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-08-01 14:21:02 -04:00
Vadim Stepanov
b2f4ffb98a
apps.get_model -> import (#2619)
# What this PR does

Remove
[`apps.get_model`](https://docs.djangoproject.com/en/3.2/ref/applications/#django.apps.apps.get_model)
invocations and use inline `import` statements in places where models
are imported within functions/methods to avoid circular imports.

I believe `import` statements are more appropriate for most use cases as
they allow for better static code analysis & formatting, and solve the
issue of circular imports without being unnecessarily dynamic as
`apps.get_model`. With `import` statements, it's possible to:

- Jump to model definitions in most IDEs
- Automatically sort inline imports with `isort`
- Find import errors faster/easier (most IDEs highlight broken imports)
- Have more consistency across regular & inline imports when importing
models

This PR also adds a flake8 rule to ban imports of `django.apps.apps`, so
it's harder to use `apps.get_model` by mistake (it's possible to ignore
this rule by using `# noqa: I251`). The rule is not enforced on
directories with migration files, because `apps.get_model` is often used
to get a historical state of a model, which is useful when writing
migrations ([see this SO answer for more
details](https://stackoverflow.com/a/37769213)). So `apps.get_model` is
considered OK in migrations (even necessary in some cases).

## 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-25 09:43:23 +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
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
Matias Bordese
91461991de
Update daily shifts by day to handle changed week start (#2263)
Related to
https://github.com/grafana/oncall/issues/2118#issuecomment-1592889257
2023-06-16 01:01:32 +00:00
Matias Bordese
3fae89ad43
Preserve schedule update_shift links on delete (#2224) 2023-06-14 19:13:35 +00:00
Matias Bordese
9e758c3bd5
Unify "name" and "title" field for oncall shift (#2239)
Porting changes from https://github.com/grafana/oncall/pull/1833
2023-06-14 19:05:19 +00:00
Joey Orlando
9dde1805aa
add mypy static type checker to backend codebase (#2151)
# What this PR does

- Adds [`mypy` static type checking](https://mypy-lang.org/) to our CI
pipeline. Currently there is still a **ton** of errors being returned by
the tool, as we'll need to fix pre-existing errors. I think we can
slowly chip away at these errors in small PRs, doing them all in one
large PR is likely very risky.
- Also, this PR starts chipping away at one of the main type errors that
we have which is accessing the `datetime` class (from the `datetime`
library) or `timedelta` function on the `django.utils.timezone` module.
Basically we should be instead accessing these two objects from the
native `datetime` module. This makes sense because the [`__all__`
attribute](https://github.com/django/django/blob/main/django/utils/timezone.py#L14-L30)
in `django.utils.timezone` does not re-export `datetime` or `timedelta`.
- splits `engine` dependencies out into `requirements.txt` and
`requirements-dev.txt`

## 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-12 12:50:33 -04:00
Matias Bordese
a536af95f4
Refresh final schedule after cached icals are dropped (#2004)
Make sure the final schedule is refreshed after dropping the cached ical
representations (sometimes the refresh final task was completed before
the cached ical files were refreshed).
2023-05-25 12:01:52 +00:00
Matias Bordese
017d98efad
Rework schedule ical export (#1783)
Related to #1501. Behind a feature flag, will migrate existing exports
to use the new ical export transparently.
2023-04-18 17:07:11 +00:00
Matias Bordese
f0c73ccc39
RRULE until values must be specified in UTC tz (#1661)
When generating ical information for an event, the RRULE until value
must be specified in UTC.

Related to https://github.com/grafana/support-escalations/issues/5426.
2023-03-30 13:53:39 +02:00
Matias Bordese
8278ad9670
Update override delete-related updates (#1599) 2023-03-23 15:45:27 +00:00
Matias Bordese
9709cfbc73
Add force option to delete web schedule shifts (#1519)
Related to #1505
Add force param to shift delete endpoint in plugin internal API.
2023-03-09 18:39:25 +00:00
Matias Bordese
721ab9fbb9
Use UTC instead of Etc/UTC when passing tz to dateutil rrule (#1414)
Fixes https://github.com/grafana/oncall-private/issues/1648
2023-02-24 20:54:20 +00:00
Matias Bordese
374f32f489 Handle no start date when calculating by day ical shift events 2023-01-02 11:53:49 -03:00
Matias Bordese
1f49c6e44a Do not include event repetitions terminated before start (until rrule) 2022-11-30 08:56:19 -03:00
Ildar Iskhakov
2052faa8d1
Fix web oncall calendars not loading (#891)
* Fix oncall schedules bug

* Update custom_on_call_shift.py
2022-11-23 20:19:52 +08:00
Matias Bordese
4aca570549 Ensure start date matches by_day selection 2022-11-08 12:24:28 -03:00
Matias Bordese
a349d39f31 Enforce until on override shifts 2022-11-07 12:35:57 -03:00
Matias Bordese
4f6734dcf5 Update daily/by-day to user group id when generating weekly shifts 2022-11-03 15:26:46 -03:00
Matias Bordese
98b187acd9 Add support for daily/by-day and custom interval 2022-11-02 16:12:16 -03:00
Matias Bordese
241283959a Enable daily/by-day shifts option for web schedules 2022-11-02 16:12:16 -03:00
Julia
461f284bb5 Merge branch 'dev' into web-schedule-fixes
# Conflicts:
#	engine/apps/schedules/ical_utils.py
#	engine/apps/schedules/models/custom_on_call_shift.py
2022-10-04 11:23:52 +03:00
Vadim Stepanov
5e272f8565
Fix failing tests due to bug in month calculations (#599) 2022-10-03 11:22:02 +01:00
Maxim Mordasov
9330b89101
Schedules alpha fixes (#541)
* schedule alpha major fixes

* Fix shift update for web schedules

* Fix priority level regex, fix getting shifts without duration

* Fix shift update for web schedules

* Fix tests for shift update

* Fix priority level test

* schedule alpha fixes

* add final schedule click handler

* fix date time picker

* fix utc timzeonr time picker

* fix utc time data

* dont use user timezone on start

Co-authored-by: Julia <ferril.darkdiver@gmail.com>
2022-09-21 11:19:59 +01:00
Julia
996e6076ab Remove unnecessary variable 2022-09-20 16:42:58 +03:00
Julia
9b9470b358 Fix shift update for web schedules 2022-09-20 13:33:33 +03:00
Julia
b1ea2b062f Fix shift update for web schedules 2022-09-20 13:19:12 +03:00
Vadim Stepanov
77984b77ab
Fix empty byday in ICAL rrule (#535) 2022-09-16 12:36:50 +01:00
Julia
f24aacfddc Fix rotation index calculation 2022-09-08 12:51:39 +03:00
Julia
e029464fa2 Update calculating rotation index for updated shift, fix schedule preview with respect to rotation index 2022-09-07 19:02:24 +03:00
Julia
9f71b5d72f Merge branch 'dev' into on-call-shifts-rotation-index 2022-09-07 18:54:39 +03:00
Julia
5c0d0ace3e Remove user group rotation reordering 2022-09-06 12:59:38 +03:00
Matias Bordese
8ff2f41550 Add comment about possible missing rrule in get_rotation_date 2022-09-05 09:48:02 -03:00
Matias Bordese
37eefe8e08 Allow empty users when previewing a web schedule shift 2022-09-02 16:45:35 -03:00
Julia
7d869f7ff9 Merge branch 'dev' into on-call-shifts-update-logic 2022-09-02 17:19:53 +03:00
Julia
36ce64b57a Revert changes in events start date calculation, fix bug with getting wrong events start date 2022-08-30 16:43:36 +03:00
Innokentii Konstantinov
4765c9b07c
Insight logs (#348)
* Entity events insight logs

* Insight logging

* Fix event for updating templates

* Format fixes

* Remove organization_log_type.py

* Simplify signature of chatops_insight_log

* insight logs formatting

* Add possibility to enable all insight logging via DynamicSetting

* Fixes

* Style fixes

* Add migration

* Fix migration
2022-08-24 12:04:44 +05:00
Matias Bordese
619b09bc6e Revisit recurring events start date respect to rotation start 2022-08-23 12:06:14 -03:00
Julia
32daaf74ce Fix tests 2022-08-18 18:27:34 +03:00
Julia
febe4cc9e0 Add calculation for rotation index 2022-08-18 18:04:38 +03:00
Julia
736bc3b348 Fix events dates calculation for old shifts and ical schedules 2022-08-17 17:04:27 +03:00
Julia
a0efa4e025 Improve update shift logic using rotation start and until dates 2022-08-16 15:38:52 +03:00
Julia
81373fd072 Add comments 2022-08-04 13:46:23 +03:00
Julia
0fd1266614 Update generating ical for on-call shifts with respect to rotation start date 2022-08-03 14:35:06 +03:00
Julia
7d65cdf411 fix soft delete for oncall shifts 2022-07-27 14:19:27 +03:00