Skip to content

Commit

Permalink
fixes and removes junk
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Watermolen committed Sep 19, 2021
1 parent 816b17c commit 0520710
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 39 deletions.
21 changes: 21 additions & 0 deletions telemetry/migrations/0002_auto_20210919_1300.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.7 on 2021-09-19 20:00

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('telemetry', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='source',
name='position',
),
migrations.RemoveField(
model_name='source',
name='time',
),
]
33 changes: 33 additions & 0 deletions telemetry/migrations/0003_auto_20210919_1305.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2.7 on 2021-09-19 20:05

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('telemetry', '0002_auto_20210919_1300'),
]

operations = [
migrations.RemoveField(
model_name='freq',
name='errors',
),
migrations.RemoveField(
model_name='freq',
name='length',
),
migrations.RemoveField(
model_name='freq',
name='position',
),
migrations.RemoveField(
model_name='freq',
name='spikes',
),
migrations.RemoveField(
model_name='freq',
name='time',
),
]
16 changes: 9 additions & 7 deletions telemetry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@

class Source(models.Model):
source = models.IntegerField()
position = models.IntegerField()
time = models.DateTimeField()
signal_system = models.CharField(max_length=50)
emergency = models.BooleanField(default=False)

def __str__(self):
return f"[{self.signal_system}] {str(self.source)}"

class Freq(models.Model):
freq = models.IntegerField()
spikes = models.IntegerField()
time = models.DateTimeField()
errors = models.IntegerField()
position = models.IntegerField()
length = models.IntegerField()

def __str__(self):
return str(self.freq/1000000)

class Call(models.Model):
call_id = models.CharField(unique=True, max_length=255)
Expand Down Expand Up @@ -66,6 +65,9 @@ class Call(models.Model):
sourceList = models.ManyToManyField(Source)
freqList = models.ManyToManyField(Freq)

def __str__(self):
return f"[{self.call_id}] {self.talkgrouptag}"

class SystemStatus(models.Model):
system = models.ForeignKey(System, unique=True, on_delete=CASCADE)

Expand Down
35 changes: 3 additions & 32 deletions telemetry/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class source:
def __init__(self, json):
self.json = json
self.source = int(json["source"])
self.position = int(float(json["position"]))
self.time = datetime.fromtimestamp(int(json["time"]))
self.signal_system = json["signal_system"]

if json["emergency"] == "false":
Expand All @@ -19,12 +17,6 @@ class freq:
def __init__(self, json):
self.json = json
self.freq = int(float(json["freq"]))
self.spikes = int(float(json["spikes"]))
self.errors = int(float(json["errors"]))
self.position = int(float(json["position"]))
self.length = int(float(json["length"]))

self.time = datetime.fromtimestamp(int(json["time"]))

class call:
def __init__(self, json):
Expand Down Expand Up @@ -85,46 +77,25 @@ def __init__(self, json):

def get_or_create_Source(sourcex:source):
if Source.objects.filter(source = sourcex.source,
position = sourcex.position,
time = sourcex.time,
signal_system = sourcex.signal_system,
emergency = sourcex.emergency):
return Source.objects.get(source = sourcex.source,
position = sourcex.position,
time = sourcex.time,
signal_system = sourcex.signal_system,
emergency = sourcex.emergency)
else:
sourceX = Source(
source = sourcex.source,
position = sourcex.position,
time = sourcex.time,
signal_system = sourcex.signal_system,
emergency = sourcex.emergency
)
sourceX.save()
return sourceX

def get_or_create_Freq(freqx:freq):
if Freq.objects.filter(freq = freqx.freq,
spikes = freqx.spikes,
time = freqx.time,
errors = freqx.errors,
position = freqx.position,
length = freqx.length):
return Freq.objects.get(freq = freqx.freq,
spikes = freqx.spikes,
time = freqx.time,
errors = freqx.errors,
position = freqx.position,
length = freqx.length)
if Freq.objects.filter(freq = freqx.freq):
return Freq.objects.get(freq = freqx.freq)
else:
FreqX = Freq(freq = freqx.freq,
spikes = freqx.spikes,
time = freqx.time,
errors = freqx.errors,
position = freqx.position,
length = freqx.length)
FreqX = Freq(freq = freqx.freq)
FreqX.save()
return FreqX

Expand Down

0 comments on commit 0520710

Please sign in to comment.