📜 ⬆️ ⬇️

Updating references from an external source with the possibility of making independent edits

There is such a site - RosYam . Once upon a time about him even wrote on Habré . I support him and I want to share the solution of one small problem that I encountered in the process. Perhaps someone will be interested.

So. There are two reference books on RosYam, which are updated from external sources. This is a directory of traffic police units and a directory of regional prosecutor's offices. They are filled with data from the official websites of the State Traffic Safety Inspectorate and the Prosecutor General’s Office . However, the data on these sites sometimes turn out to be erroneous (for example, the index of the Nizhny Novgorod traffic police), and sometimes they are not updated sufficiently quickly. And users tell us about it because they want to use relevant data.

In the classical system of simple mirroring of data from official sites, this problem is insoluble. Either we refuse regular updates and all use incorrect data, or our edits will be erased with the next update.
')
The first solution that comes to mind is to create another directory in which to enter all manual edits so that they roll right after the daily update. However, this option is bad in that such manual editing will someday become unnecessary (the official website will begin to send correct data) and after a while and simply erroneous (the unit commander changed two times in a month and a half).

Therefore, it was decided to make a smart system flexible synchronization.

Copies of the traffic police directories and prosecutor's offices were created. These directories store information that came during the last synchronization. During the current synchronization, the obtained information is compared with a copy of the directory, the changed data is detected, and only this data is updated in the combat reference book. As a result, having received information from the user about incorrect data in the directory, you can immediately make corrections on RosYam, as well as write a letter to the traffic police, so that they correct themselves. After that, I calmly rest, because I know that when the traffic police corrects the data on my report - RosYama will load it automatically and nothing will break.

If anyone is interested, the implementation code is laid out on the github: github.com/RosYama/RosYama.2/blob/master/protected/controllers/SpravController.php functions of the actionFill_gibdd_reference () and actionFill_proibe_reference ()

PS And yesterday, we also had the same housekeeper, as in the Habré, here.

Source: https://habr.com/ru/post/151842/


All Articles