mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-24 16:26:49 +00:00
32 lines
816 B
Python
32 lines
816 B
Python
# Generated by Django 3.0.1 on 2020-01-02 14:28
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from django.apps.registry import Apps
|
|
from django.db import migrations
|
|
|
|
|
|
def fill_last_errors(apps: Apps, schema_editor: Any) -> None:
|
|
Channel = apps.get_model("api", "Channel")
|
|
Notification = apps.get_model("api", "Notification")
|
|
for ch in Channel.objects.all():
|
|
error = ""
|
|
try:
|
|
n = Notification.objects.filter(channel=ch).latest()
|
|
error = n.error
|
|
except Notification.DoesNotExist:
|
|
pass
|
|
|
|
ch.last_error = error
|
|
ch.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("api", "0066_channel_last_error"),
|
|
]
|
|
|
|
operations = [migrations.RunPython(fill_last_errors, migrations.RunPython.noop)]
|