Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- response
- creacion de modelo events_configuration los cuales tienen un tiempo de frecuencia, dependiendo si es necesario:
- por ejemplo en tipos de eventos (speed, stopping, overheating)
- {
- "data":[
- {
- "id":"19",
- "type":"events_configuration",
- "attributes":{
- "id":19,
- "event_type":"speeding",
- "frequency_time":5,
- "event_attribute_value":120
- }
- },
- {
- "id":"20",
- "type":"events_configuration",
- "attributes":{
- "id":20,
- "event_type":"overheating",
- "frequency_time":5,
- "event_attribute_value":100
- }
- },
- {
- "id":"21",
- "type":"events_configuration",
- "attributes":{
- "id":21,
- "event_type":"stop",
- "frequency_time":5,
- "event_attribute_value":1
- }
- },
- {
- "id":"22",
- "type":"events_configuration",
- "attributes":{
- "id":22,
- "event_type":"inside_origin_warehouse",
- "frequency_time":5
- }
- }
- ],
- "meta":{
- "total_elements":4,
- "total_pages":1,
- "current_page":1,
- "objects_per_page":25
- },
- "links":{
- "first":"/api/v1/settings/configurations?page=1&per_page=25.0",
- "last":"/api/v1/settings/configurations?page=1&per_page=25.0",
- "self":"/api/v1/settings/configurations?page=1&per_page=25.0"
- }
- }
- Poco factible por lado de backend realizar proceso de alertas, se rompe el algoritmo debido a que cada evento tiene un inicio y fin (abierto-cerrado) , si una configuracion por ejemplo tiene un margen de 5 minutos se tendria que estar consultando cada vez que se realiza el proceso de algoritmo (debido a los waypoints entrantes) si es que estos estan dentro del tiempo de frecuencia
- 1-Solucion crear un modelo Alerta y Configuracion de Eventos por separado
- Complicaciones: Se debe consultar en cada proceso del algoritmo por los eventos abiertos y calcular si sus alertas corresponden al rango de tiempo predefinido en el modelo de alerta
- Un evento puede tener una alerta (sujeta a estar activa o inactiva, actualizandose) o varias alertas.
- 2-Solución crear modelo de configuración planteado al inicio y entregar todos los eventos luego que el front se encarge de comparar el tiempo de frecuencia definido para los distintos tipos de eventos con los objetos de eventos y mostrarlos de modo de notificaciones.
- trucks_cd = current_account.expeditions.joins([trips: :destination_warehouse], :truck, :driver).where('warehouses.address ilike (?)', "%New Numbersfort%").where(trips: { started_at: Time.now.beginning_of_day..Time.now.end_of_day, status: "in_route", active: true}).map(&:truck_id)
- waypoints_truck = Waypoint.where(waypointable_type: "Truck", waypointable_id: trucks_cd, sent_at: Time.now.beginning_of_day..Time.now.end_of_day).select('DISTINCT ON ("waypointable_id") *').order(:waypointable_id, sent_at: :desc, id: :desc)
- current_account.trucks.joins(:waypoints).where(id: trucks_cd, waypoints: { id: waypoints_truck.ids }).actived
- truck_waypoints = Waypoint.where(waypointable_type: "Truck", waypointable_id: trucks_cd, sent_at: Time.now.beginning_of_day..Time.now.end_of_day).group(:waypointable_id).maximum(:sent_at)
Advertisement
Add Comment
Please, Sign In to add comment