Skip to content

Commit

Permalink
manager: fixed sending of execute message so that only workers with a…
Browse files Browse the repository at this point in the history
…ctions will get the message, also fixed counting of workers, see #85
  • Loading branch information
MartinLiebl committed Apr 11, 2016
1 parent fe0b9de commit 350e1d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions manager/manager.py
Expand Up @@ -81,7 +81,7 @@ def __init__(self):

if rebooted:
self.setup_notifiers()
self.num_of_workers = db.session.execute(text("select count(distinct w.id) as cnt from workers w join sensors s on w.id = s.worker_id join zones z on z.id = s.zone_id join zones_setups sz on sz.zone_id = z.id join setups se on se.id = sz.setup_id where se.active_state = 1 AND w.active_state = 1")).first()[0]
self.num_of_workers = db.session.query(db.objects.Worker).join((db.objects.Action, db.objects.Worker.actions)).filter(db.objects.Worker.active_state == True).filter(db.objects.Action.active_state == True).count()

logging.info("Setup done!")

Expand Down Expand Up @@ -301,7 +301,7 @@ def got_alarm(self, ch, method, properties, body):

# iterate over workers and send "execute"
workers = db.session.query(db.objects.Worker).join((db.objects.Action, db.objects.Worker.actions)).filter(db.objects.Worker.active_state == True).filter(db.objects.Action.active_state == True).all()
self.num_of_workers = db.session.execute(text("select count(distinct w.id) as cnt from workers w join sensors s on w.id = s.worker_id join zones z on z.id = s.zone_id join zones_setups sz on sz.zone_id = z.id join setups se on se.id = sz.setup_id where se.active_state = 1 AND w.active_state = 1")).first()[0]
self.num_of_workers = len(workers)
action_message = { "msg": "execute",
"datetime": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"late_arrival":late_arrival}
Expand Down

0 comments on commit 350e1d0

Please sign in to comment.