Skip to content
Extraits de code Groupes Projets
Valider 6567f1ec rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[update] queue management

parent 4dea03ab
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"security/ir.model.access.csv", "security/ir.model.access.csv",
# datas # datas
"data/cron_import_data_wts.xml", "data/cron_import_data_wts.xml",
"data/queue_data.xml",
# views # views
"views/hall.xml", "views/hall.xml",
"views/hall_flow.xml", "views/hall_flow.xml",
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="channel_wts" model="queue.job.channel">
<field name="name">wts_channel</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>
<record id="job_function_wts_create_visitor" model="queue.job.function">
<field name="model_id" ref="hall_flow_whattheshop.model_hall_flow_zone" />
<field name="method">_wts_create_visitor</field>
<field name="channel_id" ref="channel_wts" />
<field name="retry_pattern" eval="{1: 10, 5: 20, 10: 60,}" />
</record>
<record id="job_function_wts_wts_create_passerby" model="queue.job.function">
<field name="model_id" ref="hall_flow_whattheshop.model_hall_flow_zone" />
<field name="method">_wts_create_passerby</field>
<field name="channel_id" ref="channel_wts" />
<field name="retry_pattern" eval="{1: 10, 5: 20, 10: 60,}" />
</record>
<record id="job_function_wts_create_inout" model="queue.job.function">
<field name="model_id" ref="hall_flow_whattheshop.model_hall_flow_sensor" />
<field name="method">_wts_create_inout</field>
<field name="channel_id" ref="channel_wts" />
<field name="retry_pattern" eval="{1: 10, 5: 20, 10: 60,}" />
</record>
</odoo>
...@@ -71,18 +71,18 @@ class HallFlowLog(models.Model): ...@@ -71,18 +71,18 @@ class HallFlowLog(models.Model):
if delta_days > 0: if delta_days > 0:
start_passerby = start_date start_passerby = start_date
for day in range(0, delta_days): for day in range(0, delta_days):
zone.with_delay(description=pass_desc)._wts_create_passerby( zone.with_delay(description=pass_desc, max_retries=10)._wts_create_passerby(
start_passerby, end_date, log_id start_passerby, end_date, log_id
) )
start_passerby = start_passerby + relativedelta(days=1, hours=1) start_passerby = start_passerby + relativedelta(days=1, hours=1)
else: else:
zone.with_delay(description=pass_desc)._wts_create_passerby( zone.with_delay(description=pass_desc, max_retries=10)._wts_create_passerby(
start_date, end_date, log_id start_date, end_date, log_id
) )
# Retrieve In/Out datas # Retrieve In/Out datas
for sensor in zone.sensor_ids.filtered(lambda s: s.sensor_type == "sensor"): for sensor in zone.sensor_ids.filtered(lambda s: s.sensor_type == "sensor"):
description = log_id.hall_id.name + " - " + sensor.name description = log_id.hall_id.name + " - " + sensor.name
sensor.with_delay(description=description)._wts_create_inout( sensor.with_delay(description=description, max_retries=10)._wts_create_inout(
start_date, end_date, log_id start_date, end_date, log_id
) )
......
...@@ -7,9 +7,9 @@ from odoo import fields, models ...@@ -7,9 +7,9 @@ from odoo import fields, models
from odoo.addons.api_connector.tools.date_utils import local_to_utc from odoo.addons.api_connector.tools.date_utils import local_to_utc
class HallFlowZone(models.Model): class HallFlowSensor(models.Model):
_name = "hall.flow.sensor" _name = "hall.flow.sensor"
_description = "Hall Zone Management" _description = "Hall Sensor Management"
# ------------------------------------------------------ # ------------------------------------------------------
# Fields declaration # Fields declaration
......
...@@ -5,6 +5,7 @@ from datetime import datetime ...@@ -5,6 +5,7 @@ from datetime import datetime
from odoo import fields, models from odoo import fields, models
from odoo.addons.api_connector.tools.date_utils import local_to_utc from odoo.addons.api_connector.tools.date_utils import local_to_utc
from odoo.addons.queue_job.exception import FailedJobError
class HallFlowZone(models.Model): class HallFlowZone(models.Model):
...@@ -100,6 +101,7 @@ class HallFlowZone(models.Model): ...@@ -100,6 +101,7 @@ class HallFlowZone(models.Model):
flow_ids = self.env["hall.flow"] flow_ids = self.env["hall.flow"]
backend_id = log_id.hall_id.backend_id backend_id = log_id.hall_id.backend_id
for zone in self: for zone in self:
try:
visitor_datas = backend_id._get_wifi_datas( visitor_datas = backend_id._get_wifi_datas(
url="/visitor/counthourdetails", url="/visitor/counthourdetails",
zone_ids=zone.mapped("wts_id"), zone_ids=zone.mapped("wts_id"),
...@@ -121,6 +123,8 @@ class HallFlowZone(models.Model): ...@@ -121,6 +123,8 @@ class HallFlowZone(models.Model):
"zone_id": zone.id, "zone_id": zone.id,
} }
) )
except Exception as e:
raise FailedJobError(e.__str__())
return flow_ids return flow_ids
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter