azerupi / SOTAwatch-filter

SOTAwatch filter
Mozilla Public License 2.0
3 stars 0 forks source link

Alarm is triggered for no apparent reason #21

Open azerupi opened 9 years ago

azerupi commented 9 years ago

Ed DD5LP: I am getting the alarm going off when there has been no apparent new spot on SOTAwatch (of any kind, not just that match my filter settings).

azerupi commented 9 years ago

Ed has found the cause of the bug:

I may have stumbled across the reason for the alarm going off and no new spot being displayed. If someone creates and then deletes a spot in SOTAWatch and the timing is just right, SOTAFilter will pick it up and alarm but then on the next check it's no longer present and so no longer appears in any list.

The filter has not been designed with the assumption that spots could be deleted.

To explain why this happens, let me explain how the filter "knows" when there is a new spot.

I repeatedly get a list with the spots in the latest x hours.

  1. First time: nothing happens. All the spots are new but I don't consider them to be new because I have no previous list in memory. I store this list into memory.
  2. Second time: I get a new list. Which should be the same except if there is a new spot. I compare the last spot from list in memory (previous list) to the new list until I find the same spot in the new list. All the spots above this spot should thus be new.

But when a spot is deleted the last spot in the previous list is the deleted spot, this spot does not exist anymore in the new list. So all the spots are considered to be new. Triggering an alarm and showing all the spots in green.

Here is a diagram to demonstrate what happens:

sota

One or two alarms are triggered depending on the case:

In both cases, the alarm will be triggered and there will be no new spot to see in the list.