eladnava / pikud-haoref-api

A Node.js wrapper library for Pikud Haoref's unofficial rocket alert API.
Apache License 2.0
71 stars 11 forks source link

Could you please check if the cities file is up to date? #13

Closed agamsol closed 2 years ago

eladnava commented 2 years ago

Hi @agamsol, Thanks for bringing this to my attention. The HFC has indeed made modifications to both the city and zone names.

The cities json file has been updated in this commit. I will be releasing updates to the Android & iOS app with the new cities & zones published by the HFC.

agamsol commented 2 years ago

May I ask from where do you crawl the data?

eladnava commented 2 years ago

Hi @agamsol, The cities.js utility scrapes the cities data from the HFC website JSON files (in both Hebrew & English):

https://www.oref.org.il/Shared/Ajax/GetCitiesMix.aspx?lang=he https://www.oref.org.il/Shared/Ajax/GetCitiesMix.aspx?lang=en

agamsol commented 2 years ago

Could you tell me what does id represent in the alert.json provided from Pikud Haoref?

Here is a alert response from about 2 days ago

{
  "id": "133024095050000000",
  "cat": "1",
  "title": "ירי רקטות וטילים",
  "data": [
    "אחוזם"
  ],
  "desc": "היכנסו למרחב המוגן ושהו בו 10 דקות"
}

I couldn't find any explanation for any of the ID's although I can assume what they belong to, except for the id and cat

eladnava commented 2 years ago

Hi @agamsol, It is most likely a unique auto-incrementing database identifier which Pikud Haoref assigns to every new alert. You can make use of this field to keep track of whether you have seen this alert before, or if it's the first time.

agamsol commented 2 years ago

So after the alert.json indicates that there is a threat I need to save the ID and keep checking if it has been changed in alert.json and if the new Alert's ID does not match the previous ID it indicates a new threat (at a short time since last threat)?

eladnava commented 2 years ago

Hi @agamsol, Correct. If the ID changes for the same areas indicated in data it indicates a new alert for those areas.

agamsol commented 2 years ago

but when the ID changes it should overwrite the existing cities in the DATA array no? there is no case where the DATA has been updated and the ID remains the same?

eladnava commented 2 years ago

Hi @agamsol, The ID is different on a per-alert basis. Every element in the alerts.json array has a unique ID which you can use to track whether you have processed the individual alert before.

agamsol commented 2 years ago

If I wanted to update citiesArchive.js, what file do I need to launch in order to generate the latest file?

eladnava commented 2 years ago

Hi @agamsol, I've just updated it 2 days ago, there haven't been any changes since. However, example/cities.js is the file to run.

agamsol commented 2 years ago

Thank you very much, I really appreciate everything!

agamsol commented 2 years ago

By any chance, do you know all of the possible values for title inside the alerts.json file?

Quick debug showed this:

image

although I want to make sure this is what it can provide, for example- I know it can provide חדירת מחבלים which doesn't show in the image above

eladnava commented 2 years ago

Hi @agamsol, Sorry, I do not know the full list of possible values for this field.