Problem/Motivation

Geocoder plugin for Google Places API queries all fields during Place Details API call, hence can result in extra billing if contact or atmosphere fields are returned.

Fields (Place details) in Places API

Steps to reproduce

Call geocode for the place that have contact or/and atmosphere data.

Proposed resolution

Since only geometry and formatted_address are used, add "&fields=geometry,formatted_address" to the query string when calling place details API.

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

valery.suslov created an issue. See original summary.

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

secretsayan’s picture

Status: Active » Needs review
christianadamski’s picture

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

This change does a lot more though...

christianadamski’s picture

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

Please remove or explain the placeId usage and the sessionToken

secretsayan’s picture

Status: Needs work » Needs review
secretsayan’s picture

@christianadamski There are two enhancements in this PR to reduce billing:

1. We are retrieving geometry and formatted_address only instead of all the fields.
2. We are binding our api calls in a single session token as explained in documentation here https://developers.google.com/maps/documentation/places/web-service/deta...

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

aaronbauman’s picture

Opened a new branch to try a 4.x version of this patch, but 4.x Places appears to be broken / unsupported.

christianadamski’s picture

Status: Needs review » Fixed

@aaronbauman - Where is the 4.x MR? Did I merge that already? Can't find it. What is broken?

For 3.x merged. @secretsayan Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

aaronbauman’s picture

There is no Places API plugin in 4.x, so I was unable to create a similar patch.
Is Places API support deprecated from 4.x on purpose?

Found the Places API sub-sub-module.
https://git.drupalcode.org/project/geolocation/-/blob/4.x/modules/geoloc...

I can work on a 4.x MR, maybe later today.

aaronbauman’s picture

Version: 8.x-3.x-dev » 4.x-dev
Status: Fixed » Needs review

Opened MR 138 against 4.x ready for review

In addition to the session token, locally I'm also using Drupal's cache to store places results for Google's recommended 30 days.

This has given me a massive, massive reduction in API usage.

I will post this patch to a separate thread.

christianadamski’s picture

Status: Needs review » Needs work

Hey nice. If possible, please fix the code style issues.

FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------
65 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
| | (Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines)
67 | WARNING | [ ] Line exceeds 80 characters; contains 117 characters (Drupal.Files.LineLength.TooLong)
69 | WARNING | [ ] Line exceeds 80 characters; contains 121 characters (Drupal.Files.LineLength.TooLong)
72 | ERROR | [x] Space found before comma in argument list
| | (Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma)
91 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters (Drupal.Files.LineLength.TooLong)

You can see them on the MR page as well.

Thank you!

christianadamski’s picture

Status: Needs work » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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