Commit graph

1885 commits

Author SHA1 Message Date
Pēteris Caune
12f6f59e0a
Refactor and improve type hints 2022-11-30 14:02:03 +02:00
Pēteris Caune
ac2f2fefc2
Improve sendreports tests 2022-11-30 12:17:16 +02:00
Pēteris Caune
34bd608acd
Update Profile.send_report to prepare weekly totals for weekly reports
Fixes: #736
2022-11-30 11:51:00 +02:00
Pēteris Caune
796c6b9272
Add Check.downtimes_by_boundary, add hc.lib.date.week_boundaries
cc: #736
2022-11-30 10:49:42 +02:00
Pēteris Caune
f4dc008c55
Refactor Check.downtimes to handle any boundaries, not just monthly
cc: #736
2022-11-30 10:29:42 +02:00
Pēteris Caune
c3e6fca6a7
Fix "get body" views to preserve body bytes, avoid string conversions 2022-11-28 14:48:55 +02:00
Pēteris Caune
ea2f2d9ec0
Add more tests 2022-11-28 14:04:57 +02:00
Pēteris Caune
9e9490d815
Move test to separate file, remove trailing slash from URL 2022-11-28 13:28:08 +02:00
Martin Lablans
a55a2692dc
Allow to retrieve a ping's body (#737)
Add /api/v1/checks/<uuid>/pings/<n>/body endpoint for retrieving ping body (#737)
2022-11-28 13:21:26 +02:00
Pēteris Caune
8930bedd4a
Refactor the other "edit channel" views, add type hints 2022-11-25 12:48:04 +02:00
Pēteris Caune
346ebc184c
Refactor hc.front.views.ntfy_form, add type hints 2022-11-25 11:23:58 +02:00
Pēteris Caune
c275bf09f1
Improve type hints 2022-11-25 10:07:57 +02:00
Pēteris Caune
646aa1cb48
Add ".txt" suffix to the filename when downloading ping body
Fixes: #738
2022-11-24 18:22:34 +02:00
Pēteris Caune
413b97c48f
Fix ntfy edit form initialization 2022-11-24 14:48:19 +02:00
Pēteris Caune
d2810d62d8
Simplify AddPushoverForm 2022-11-24 13:43:26 +02:00
Pēteris Caune
390bb781ca
Refactor duplicated code 2022-11-24 13:26:09 +02:00
Pēteris Caune
3dcc7d60a2
Add ntfy integration
Fixes: #728
2022-11-24 12:09:53 +02:00
Pēteris Caune
9977789cac
Add a special case for the last ping body containing backticks 2022-11-22 20:22:37 +02:00
Sebastian Schneider
6481ed0d19
Add last ping body body to Slack notifications (#735)
Co-authored-by: Sebastian Schneider <sebastian.schneider@boxine.de>
Co-authored-by: Pēteris Caune <cuu508@gmail.com>
2022-11-22 17:50:11 +02:00
Pēteris Caune
75188e218e
Fix duration calculation in the "Get Pings" API call 2022-11-11 13:04:08 +02:00
Pēteris Caune
7458770b41
Improve alerting logic when run IDs are used
* Add Check.last_start_rid field
* Fill Check.last_start_rid on every start event
* Clear Check.last_start on every "fail" event
* Clear Check.last_start on success event if either case is true:
 - the event's rid matches Check.last_start_rid
 - the event does not specify rid

In human terms, the alerting logic will be: we track the
execution time of the most recent "start" event only. It would
take a major redesign to track the execution time of all
concurrent "start" events and send alerts when *any* of them
overshoots the time budget. So, whenever we see a "start" event,
the timer resets.

Example:

* 00:00 client sends start signal with rid=A, timer starts
* 00:10 client sends start signal with rid=B, timer resets
* 00:20 client sends success signal with rid=A, timer
  does not reset because rid A does not match the rid seen in
  the most recent start signal (it was B)
* 00:30 the grace time runs out, the check's status shows
  as started + failed

At this point the check can be reset to a healthy state in 3
different ways:

* send a success signal with rid=B
* send a failure signal with any rid value or without it
* send a success signal without a rid value
2022-11-09 19:01:22 +02:00
Pēteris Caune
e58a9ee71e
Add protection for n queries problem in _get_events
If every fetched ping is a success event, and has an unique
run ID, then we cannot determine the duration just from the
fetched data, and must fall back to Ping.duration(). This
would generate a SQL query per displayed ping.

The solution is to count how many times we would need to use
the fallback, and if it goes above some threshold (currently,
10 times), then disable duration display altogether.
2022-11-08 12:41:46 +02:00
Pēteris Caune
8f249b8c59
Refactor test case some more 2022-11-08 12:12:01 +02:00
Pēteris Caune
7591fe35dc
Refactor test case 2022-11-08 11:57:15 +02:00
seidnerj
b6027fa126
Added support for a "run id" parameter (#722)
Add support for specifying a run ID via a "rid" query parameter

cc: #461
2022-11-08 11:34:26 +02:00
Pēteris Caune
024622c146
Fix tests 2022-11-02 14:48:22 +02:00
Pēteris Caune
ccfcf26e65
Update Mattermost setup instructions 2022-11-02 14:45:44 +02:00
Pēteris Caune
d3406aef25
Fix the most recent ping lookup in the "Ping Details" dialog 2022-11-01 13:42:09 +02:00
Pēteris Caune
e29235c5a5
Improve tests 2022-11-01 12:15:54 +02:00
Pēteris Caune
d100cb7ead
Fix duration calculation bug in _get_events
The bug: _get_events sometimes does not have enough data to
calculate all durations correctly (some needed "start" events
may be outside the fetched data). The fix is to fall back to
Ping.duration() in these cases.
2022-11-01 12:04:14 +02:00
Pēteris Caune
30fcc6a936
Fix duration calculation bug 2022-11-01 10:29:43 +02:00
Pēteris Caune
a87c3bf04b
Rewrite to avoid self.owner access to save a SQL query 2022-11-01 09:56:34 +02:00
Pēteris Caune
26b6e20fda
Fix hc.front.views.ping_details to set duration on all ping instances
The code in hc.front.views.ping_details calculates durations
and sets them on the Ping.duration field, overriding the cached
property. But, it only does this for pings where the duration can
be calculated. If there's a streak of "success" pings with no
"start" pings between, the loop will not set the Ping.duration
field for most of them. So, when rendering the template, the
property code will run and cause an additional SQL query for each
ping. The fix is, in hc.front.views.ping_details, to set the
Ping.duration field for each and every ping.
2022-11-01 09:22:29 +02:00
seidnerj
c82c1a3a4a
Added duration to ping details (#720)
* Added duration to ping details. This is useful on a device with a small screen, since the duration cannot be seen in the main view so now one can see it in the ping's details.
* Changed terms across the board from "delta" to "duration"
* timedelta is now consistently imported as "td" across the entire project (even in Django generated migration files)
2022-11-01 09:18:34 +02:00
Pēteris Caune
c26dbc96f5
Refactor render_docs to support multiple docs directories 2022-10-28 12:05:01 +03:00
Pēteris Caune
85be1ce481
Fix the link to the Signal CAPTCHA form 2022-10-28 08:28:32 +03:00
Pēteris Caune
20a5e3ffca
Add tests and usability tweaks for the signal_captcha view 2022-10-27 13:00:12 +03:00
Pēteris Caune
8d75f1adc3
Add a form for submitting Signal CAPTCHA solutions 2022-10-27 11:57:52 +03:00
Pēteris Caune
a189872938
Improve type hints 2022-10-20 13:03:10 +03:00
Pēteris Caune
895e8e856a
Improve type hints 2022-10-20 12:24:50 +03:00
Pēteris Caune
e4a956679e
Move port scrubbing to hc.api.views.ping, add test case
cc: #714
2022-10-20 11:59:19 +03:00
Cam
5aa4c64a6f Add IPv4 check to guard clause 2022-10-20 11:41:03 +03:00
Cam
ca1b9a6b12 Remove port portion of remote_addr 2022-10-20 11:41:03 +03:00
Pēteris Caune
a944c05f68
Upgrade to fido2 1.1.0 and simplify hc.lib.webauthn 2022-10-19 09:16:01 +03:00
Pēteris Caune
03f46630eb
Format with black 2022-10-17 17:02:11 +03:00
Pēteris Caune
161430fb10
Sort imports and add "from __future__ import annotations" 2022-10-17 16:52:15 +03:00
Pēteris Caune
5969e940a5
Switch to using "from __future__ import annotations" 2022-10-17 16:29:48 +03:00
Pēteris Caune
7ac8458b07
Optimize the "Get a List of Existing Checks" API call 2022-10-12 17:02:47 +03:00
Pēteris Caune
11997e75c8
Fix test_tokenbucket failure 2022-10-09 12:22:46 +03:00
Pēteris Caune
963f1758de
Improve type hints 2022-10-09 11:51:13 +03:00