Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associations with old data are not removed/updated. #24

Closed
faultyserver opened this issue Aug 22, 2016 · 3 comments
Closed

Associations with old data are not removed/updated. #24

faultyserver opened this issue Aug 22, 2016 · 3 comments
Labels
Milestone

Comments

@faultyserver
Copy link
Member

Vehicles are continuously sending depart events to stations that they left long ago, meaning that dissociate is either not working as expected (or is not being called appropriately), or the last_station property for the vehicles is not being properly.

@faultyserver
Copy link
Member Author

Testing has shown that dissociate is indeed working properly, so there is most likely an issue in Conductor that is keeping the method from being called appropriately.

@faultyserver faultyserver added this to the v1.0 milestone Sep 2, 2016
@faultyserver
Copy link
Member Author

After lots of confusion over how dissociate could be working, but somehow returning true when the association shouldn't have existed, I think I've finally determined why this is happening.

For CityBus, vehicle.last_station and vehicle.next_station are sourced different locations; last_station comes from DoubleMap, and next_station comes from TripSpark. It is perfectly reasonable to assume that these sources can be out-of-sync at any time. If DoubleMap updates before TripSpark does (which is pretty common), last_station will be the same as next_station until TripSpark updates appropriately.

So, the issue here is not that the associations are not removed, but rather that the associations are being removed and re-added in update cycles where the two sources are out-of-sync.

The solution that I've come up with is to change Conductor's vehicles:update handler to something like this:

if dissociate(last_station, vehicle)
  fire(:depart)
end
unless next_station == last_station
  associate(next_station, vehicle)
end

Having the dissociation come first ensures that the depart event is sent as soon as last_station changes. Then, the guard clause around associate means that the next_station is only associated if it is not the same as the last_station, ensuring that the sources are synchronized.

Will test and report back.

faultyserver added a commit that referenced this issue Sep 24, 2016
…vehicle.last_station`.

The issue described in #24 was occuring because `next_station` and `last_station` were referring to the same station. That meant that after `dissociate`ing the `last_station` and sending a `depart` event to that station, it was being re`associated`, causing Conductor to essentially assume that the previous cycle didn't happen, and thus resend the `depart` event.

Adding a `next_station != last_station` guard clause around `associate(next_station, vehicle)` seems to have fixed this issue.
@faultyserver
Copy link
Member Author

Closed by 54cb98a. The guard clause given above seems to have worked properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant