Problem/Motivation

Sometimes the conversion takes time based on the plugin used to geocode the fields, which keeps the node save on hold, and the user waiting for the node to be saved. This can get even heavier when webform are used to populate the node's data and include Geo conversion for address fields.

Proposed resolution

Update geocoder_field_entity_presave() to add items to the queue and be processed via cron at a later time as defined.
Admin option in settings at global level to enable/disable processing via a queue.

Remaining tasks

  1. Update/Review Proposed resolution
  2. Implement the Proposed solution

Issue fork geocoder-3283924

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joshua1234511 created an issue. See original summary.

itamair’s picture

Status: Active » Postponed (maintainer needs more info)

Well ... indeed Geocoding processing takes so long?
How "soo long"??
I personally never experienced more than few seconds (5 at my most) ... unless there is a network or response issue.
I like Drupal Queue API and being using it quite a lot but ...
in this case you basically want to defer a second (Geocoding) part of each Content/Entity save at a later Cron run ... right?
So if Cron runs every 15 mins (or more ...) the Geocoding feedback/outcome would appear/happen (in the Content) 15 mins later (or more)?

It doesn't look the best functional UX to me ... and for sure this should be somehow configurable (not to be the only and default Geocoding behaviour).

Feel free (and welcome) to add more details to your POC here, and eventually a patch/MR ...

joshua1234511’s picture

Status: Postponed (maintainer needs more info) » Needs review

Yes, correct
What I meant to say is use Drupal Queue API to process the geocoding.

A scenario where the node is using geocoding and is being created using webform node submissions.
Or in case of headless sites, where forms are used to populate/create entities.
in such a case the user from time outs or has to wait long enough for the process to complete to get the response.

Raised a MR with a POC on the same.

Only local images are allowed.

Only local images are allowed.

kristen pol’s picture

Status: Needs review » Needs work

I added a few comments for nitpicks/typos.

joshua1234511’s picture

Status: Needs work » Needs review

Updated the MR with the requested changes.

itamair’s picture

Status: Needs review » Reviewed & tested by the community

Nice! ... & thanks both of you.
I tested and this works nice/great.
I just added 2 refinements commits (actually I removed the GeocoderProcess abstract class that doesn't look needed to me).
Marking this as RTBC ...
Are you ok with merging this into Dev branch and making it part of the new Geocoder release?

joshua1234511’s picture

Yes, this can be merged and made available for dev branch.
Just a note, it would be good to have test cases for the same, either in this same issue or a new issue linked to this.

itamair’s picture

eh ... and would you provide test cases also?
Usually it is a task for the developer ...

joshua1234511’s picture

Was going through the test case in module, it does have a kernel random test added.
For the above case it can be extensive and dependency.
We can go head and get this functionality included.

itamair’s picture

Thanks a lot @joshua1234511 ... sincerely since I took over this Geocoder maintenance (from Drupal 8) I didn't really cared updating and extending the test coverage base (not enough time also for that).
Please go ahead if you feel comfortable with that ... in the proper spirit of the Drupal community.

itamair’s picture

Please note that new release geocoder 8.x-3.29 made some amends on the existing GeocoderTest ...

DieterHolvoet made their first commit to this issue’s fork.

DieterHolvoet changed the visibility of the branch 8.x-4.x to hidden.

dieterholvoet’s picture

Status: Reviewed & tested by the community » Needs review

I started a new branch from 4.x and improved the implementation, both in the old 3.x and new 4.x branch:

  • Simplified some naming and labels
  • Moved the queue ID to a constant
  • Stopped storing the whole entity object in the queue item data. Makes the row unnecessary big & makes it so the queue worker gets a possibly outdated version of the entity.
  • Removed the drupal_register_shutdown_function. Instead, I added a check that only saves the entity if any values were changed, also preventing infinite loops but without needing hacky code.
itamair’s picture

Status: Needs review » Fixed

Ok. QA and Reviewed this on, merging into 8.x-4.x-dev ...

itamair’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.