Индексы на воркеры
This commit is contained in:
parent
287a2be16e
commit
b36b4e8fd4
29
apps/workerslocation/migrations/0012_auto_20250605_1627.py
Normal file
29
apps/workerslocation/migrations/0012_auto_20250605_1627.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Generated by Django 3.2.25 on 2025-06-05 16:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('workerslocation', '0011_alter_workerstracking_options'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveIndex(
|
||||
model_name='workerstracking',
|
||||
name='workersloca_worker__d7aec1_idx',
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='workerslocation',
|
||||
index=models.Index(fields=['name'], name='workersloca_name_cc95e1_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='workerslocation',
|
||||
index=models.Index(fields=['active', 'update_time'], name='workersloca_active_c3b753_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='workerstracking',
|
||||
index=models.Index(fields=['worker', 'time'], name='workersloca_worker__f6ee2a_idx'),
|
||||
),
|
||||
]
|
||||
@ -38,7 +38,8 @@ class WorkersLocation(models.Model):
|
||||
|
||||
def to_dict(self, time_filter=None):
|
||||
worker_name = self.name if self.name else self.uid
|
||||
worker_connection_condition = self.get_worker_condition(self.update_time)
|
||||
worker_connection_condition = self.get_worker_condition(
|
||||
self.update_time)
|
||||
if self.icon is not None:
|
||||
icon_path = self.icon.image.url
|
||||
else:
|
||||
@ -57,7 +58,8 @@ class WorkersLocation(models.Model):
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def get_worker_condition(update_time: datetime.datetime, calc_from: datetime.datetime=None) -> str:
|
||||
def get_worker_condition(update_time: datetime.datetime,
|
||||
calc_from: datetime.datetime = None) -> str:
|
||||
if calc_from:
|
||||
now = calc_from
|
||||
else:
|
||||
@ -81,14 +83,8 @@ class WorkersLocation(models.Model):
|
||||
verbose_name = "объект"
|
||||
verbose_name_plural = "объекты"
|
||||
indexes = [
|
||||
models.Index(
|
||||
fields=[
|
||||
"uid",
|
||||
],
|
||||
),
|
||||
models.Index(
|
||||
fields=[
|
||||
"update_time",
|
||||
]
|
||||
),
|
||||
models.Index(fields=["uid", ]),
|
||||
models.Index(fields=["name", ]),
|
||||
models.Index(fields=["update_time", ]),
|
||||
models.Index(fields=["active", "update_time", ]),
|
||||
]
|
||||
|
||||
@ -59,14 +59,6 @@ class WorkersTracking(models.Model): # Передвижение персона
|
||||
verbose_name = "Передвижение сотрудника"
|
||||
verbose_name_plural = "Передвижения сотрудников"
|
||||
indexes = [
|
||||
models.Index(
|
||||
fields=[
|
||||
"worker",
|
||||
]
|
||||
),
|
||||
models.Index(
|
||||
fields=[
|
||||
"time",
|
||||
]
|
||||
),
|
||||
models.Index(fields=["worker", "time"]),
|
||||
models.Index(fields=["time",]),
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user