fxi: 优化定时任务仅更新1代设备
This commit is contained in:
parent
5767c5aee0
commit
3d9c4d6cc9
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2024-04-02 04:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mosquito', '0032_deviceinfo_last_connect'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='deviceinfo',
|
||||
name='chip_type',
|
||||
field=models.CharField(blank=True, max_length=30, null=True, verbose_name='芯片类型'),
|
||||
),
|
||||
]
|
|
@ -78,6 +78,7 @@ LED_CHOICE = (
|
|||
class DeviceInfo(models.Model):
|
||||
device_id = models.CharField(max_length=100, unique=True, verbose_name='设备ID')
|
||||
device_name = models.CharField(max_length=100, blank=True, null=True, verbose_name='设备名称')
|
||||
chip_type = models.CharField(max_length=30, blank=True, null=True, verbose_name='芯片类型')
|
||||
longitude = models.FloatField(blank=True, null=True, verbose_name='经度')
|
||||
latitude = models.FloatField(blank=True, null=True, verbose_name='维度')
|
||||
location = models.CharField(max_length=100, blank=True, null=True, verbose_name='地理位置')
|
||||
|
|
|
@ -51,7 +51,8 @@ def get_daily_statistic(enable_container=False):
|
|||
qs = DeviceCount.objects.raw('select id, date(data_time) as date from device_count group by date')
|
||||
if qs:
|
||||
tz = pytz.timezone("UTC")
|
||||
device_list = {item.device_id for item in DeviceInfo.objects.distinct()}
|
||||
device_list = {item.device_id for item in
|
||||
DeviceInfo.objects.filter().exclude(chip_type='AIR-V2').distinct()}
|
||||
for item in device_list:
|
||||
device_container[item] = set()
|
||||
for q in qs:
|
||||
|
@ -217,7 +218,9 @@ def update_mosq_device_info():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# a, b = get_daily_statistic()
|
||||
a, b = get_daily_statistic()
|
||||
print(a)
|
||||
print(b)
|
||||
# print(a, b)
|
||||
update_mosq_device_info()
|
||||
# update_mosq_device_info()
|
||||
# update_mosql_device_location()
|
||||
|
|
Loading…
Reference in New Issue