Индексы
This commit is contained in:
parent
e3c5fbb902
commit
0c81b83ce9
25
apps/gto/migrations/0020_auto_20250605_1616.py
Normal file
25
apps/gto/migrations/0020_auto_20250605_1616.py
Normal file
@ -0,0 +1,25 @@
|
||||
# Generated by Django 3.2.25 on 2025-06-05 16:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gto', '0019_alter_equipmenttracking_options'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveIndex(
|
||||
model_name='equipmenttracking',
|
||||
name='gto_equipme_equipme_7c0944_idx',
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='equipment',
|
||||
index=models.Index(fields=['block', 'time'], name='gto_equipme_block_93a763_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='equipmenttracking',
|
||||
index=models.Index(fields=['equipment', 'time'], name='gto_equipme_equipme_c4b351_idx'),
|
||||
),
|
||||
]
|
||||
@ -65,22 +65,22 @@ class Equipment(models.Model): # Оборудование
|
||||
connection_condition = self.get_condition(
|
||||
self.time)
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"lat": self.lat,
|
||||
"lon": self.lon,
|
||||
"time": self.time.strftime("%d.%m.%Y %H:%M:%S"),
|
||||
"iso_time": self.time.isoformat(),
|
||||
"statenum": self.statenum,
|
||||
"model": self.model,
|
||||
"icon": icon,
|
||||
"garagenum": self.garagenum,
|
||||
"condition": connection_condition,
|
||||
}
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"lat": self.lat,
|
||||
"lon": self.lon,
|
||||
"time": self.time.strftime("%d.%m.%Y %H:%M:%S"),
|
||||
"iso_time": self.time.isoformat(),
|
||||
"statenum": self.statenum,
|
||||
"model": self.model,
|
||||
"icon": icon,
|
||||
"garagenum": self.garagenum,
|
||||
"condition": connection_condition,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def get_condition(update_time: datetime.datetime,
|
||||
calc_from: datetime.datetime = None) -> str:
|
||||
calc_from: datetime.datetime = None) -> str:
|
||||
if calc_from:
|
||||
now = calc_from
|
||||
else:
|
||||
@ -96,7 +96,6 @@ class Equipment(models.Model): # Оборудование
|
||||
else:
|
||||
return "danger"
|
||||
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
String for representing the Model object (in Admin site etc.)
|
||||
@ -108,19 +107,8 @@ class Equipment(models.Model): # Оборудование
|
||||
verbose_name = "объект"
|
||||
verbose_name_plural = "объекты"
|
||||
indexes = [
|
||||
models.Index(
|
||||
fields=[
|
||||
"uid",
|
||||
]
|
||||
),
|
||||
models.Index(
|
||||
fields=[
|
||||
"name",
|
||||
]
|
||||
),
|
||||
models.Index(
|
||||
fields=[
|
||||
"time",
|
||||
]
|
||||
),
|
||||
models.Index(fields=["uid", ]),
|
||||
models.Index(fields=["name", ]),
|
||||
models.Index(fields=["time", ]),
|
||||
models.Index(fields=["block", "time"]),
|
||||
]
|
||||
|
||||
@ -62,19 +62,7 @@ class EquipmentTracking(models.Model): # Передвижение оборуд
|
||||
verbose_name = "Передвижение оборудования"
|
||||
verbose_name_plural = "Передвижение оборудования"
|
||||
indexes = [
|
||||
models.Index(
|
||||
fields=[
|
||||
"eventid",
|
||||
]
|
||||
),
|
||||
models.Index(
|
||||
fields=[
|
||||
"equipment",
|
||||
]
|
||||
),
|
||||
models.Index(
|
||||
fields=[
|
||||
"time",
|
||||
]
|
||||
),
|
||||
models.Index(fields=["eventid"]),
|
||||
models.Index(fields=["equipment", "time"]),
|
||||
models.Index(fields=["time"]),
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user