geocoder-php / BazingaGeocoderBundle

Integration of the Geocoder library into Symfony.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduce # of queries triggered

xavismeh opened this issue · comments

commented

When using the doctrine event listener and updating an entity which supports geocoding, the query to the provider will be triggered, regardless if data has change or not.

Since I can't tell yet if I'll be able to submit a PR in that regard, here is what I have identified: in Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener::geocodeEntity, a second argument containing the previous value of $address — as computed either in line 92 or 94 — to prevent an unecessary query if the value is still the same.

Also, while writing this, I have the feeling that it's not possible to "unset" coordinates after "clearing" an address informations. But that's just an assumption and should be subject to a different ticket :)

Hello,
You could use cache that would solve your problem :)
But yes, this could be solved in the GeocoderListener.
Will you like to submit a PR? :)

About coordinates.. Changing this I think would be a BC break if people relies on this for data to be preserved 🤔

commented

Hello @norkunas,

In this situation it's not cache related: cache should be in charge to prevent heavy call, but data needs to be accessed. However, in this situation, this is about not accessing data.
However, I am not sure I could make the PR soon and that's why I've shared my findings in case someone would want to take over on that.