Completed
Push — master ( b0fc82...6c4ac7 )
by
unknown
02:17 queued 12s
created

update_crashes()   A

Complexity

Conditions 4

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
dl 0
loc 7
rs 9.2
c 1
b 0
f 0
1
# -*- coding: utf-8 -*-
2
# Generated by Django 1.9.6 on 2017-04-17 06:47
3
from __future__ import unicode_literals
4
5
from django.db import migrations
6
7
8
def update_crashes(apps, schema_editor):
9
    Crash = apps.get_model("crash", "Crash")
10
    crashes = Crash.objects.all().iterator()
11
    for obj in crashes:
12
        obj.os = obj.stacktrace_json.get('system_info', {}).get('os', '') if obj.stacktrace_json else ''
13
        obj.build_number = obj.meta.get('ver', '') if obj.meta else ''
14
        obj.save()
15
16
17
class Migration(migrations.Migration):
18
19
    dependencies = [
20
        ('crash', '0029_crash_build_number'),
21
    ]
22
23
    operations = [
24
        migrations.RunPython(
25
            update_crashes,
26
            reverse_code=migrations.RunPython.noop
27
        ),
28
    ]
29