Events missing VenueLat and VenueLng meta_key values

Home Forums Calendar Products Events Calendar PRO Events missing VenueLat and VenueLng meta_key values

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #134357
    irishrunner16
    Participant

    One of my clients alerted me to the fact that their event is not showing up in location search on my event calendar. It does show up in date and keyword searches, but for some reason it is not showing up in location search (in any of the views).

    I’m concerned that this may not be an isolated case, as this event was one of about 3,000 I had uploaded via the CSV Importer (although I know that the files were correctly encoded in UTF-8). The event in question does not appear to have meta_key values for _VenueLat or _VenueLng. Only _VenueGeoAddress is in the database for that post_id (and possibly others). There are 3,144 rows in my database for _VenueGeoAddress and 2,754 that have _VenueLat and _VenueLng. Would that be the source of the issue? If so, is there any way I can have the geo coordinates regenerated for any venues that are missing them?

    The missing event, which is in Portland, ME: Portland Waterfront 5K
    Link to a search for events occurring on Nov 8th or after, in which the event is shown correctly.
    Link to a keyword search, in which the event is shown correctly.
    Link to a search for events near Portland, ME (the Nov. 8th event does not appear, when it should)

    Thanks,
    Sean

    #135120
    irishrunner16
    Participant

    I’ve confirmed there are other events missing the _VenueLat and _VenueLng meta_keys. They include events that have been submitted via Community Events, so it appears there’s an ongoing issue since both events uploaded with the CSV Importer and added via Community Events are missing those meta_keys. I’m perplexed since it appears the majority of the events in our database are correctly having those rows created when the event is added to the database.

    #135386
    Barry
    Member

    That is strange. If you visit the Events Settings screen do you see a button to “Fix Venues Data”?

    #135414
    irishrunner16
    Participant

    Hi Barry,
    Thanks for the quick reply. I looked throughout the Events settings but am not seeing any such option. Sounds like it could be what I need. Is that a back-end feature that I’d need you guys to send me the code for and install/use at my own risk?

    #135714
    irishrunner16
    Participant

    Although that’d probably only fix the existing venues…would also need a permanent fix as well. I’m trying further testing here to see if I can figure out what the cause might be.

    In the meantime please do let me know if there is any way to get the Longitude/Latitude values created for all of the existing events (hoping the “Fix Venues Data” feature you mentioned might do just that?)

    #136336
    Barry
    Member

    OK, so:

    They include events that have been submitted via Community Events

    I wonder here if this is a side effect of a known bug whereby if the submissions are set to draft or pending review before being published various venue fields are inadvertently dropped. Is that the sort of workflow you’re following? If so, we’re working on this one as I write!

    Beyond that, though of course that’s a bit of a block in itself, this mechanism seems to be working and for instance if submissions are set to be published immediately it all works as expected, best I can tell.

    both events uploaded with the CSV Importer and added via Community Events are missing those meta_keys

    I tested out importing venue data (of course, they need to be well formed addresses – or at least close to being well formed) and it worked as expected. The geodata was created and saved and it worked as expected.

    So I’m not sure what’s going on, but it does seem to be specific to your site. Have you tested out these operations (submitting events via Community Events and venue imports) with all other plugins deactivated and only a default, unmodified theme in place?

    #136902
    irishrunner16
    Participant

    1. Yes, I do have the default status of events set to be “pending review”. So if that is indeed a bug and can lead to the _VenueLat and _VenueLng meta_keys not being created when an event is submitted, I hope the fix will include a way for those rows to be created for any venue in which they don’t already exist?

    2. I’ll do some further testing this weekend to see if I can duplicate the import issue on a default theme with no non-TEC plugins activated. Thanks.

    #137863
    irishrunner16
    Participant

    I haven’t been able to pinpoint why some of the Venues of my import did not generate _VenueLat and _VenueLng values. However, other than a few random venues, it looks like all imported Venues after ~2,725 did not have those meta values/rows created. So perhaps it was related to a timeout issue or something similar.

    In any case, I tried a few different things to see what might create those missing meta values for all venues:
    1. Tried re-uploading a few of those Venues, but doing so didn’t create the missing values.
    2. I then tried deleting the _VenueGeoAddress for some venues, but using the “Fix geolocation data” option that appeared in the calendar settings only recreated the _VenueGeoAddress for the venues; no _VenueLat or _VenueLng was created.
    3. Next, I deleted the _VenueGeoAddress meta value for a venue, and went into the Venue editor. I saved the venue, but again, it only created the VenueGeoAddress and not the Lat or Lng meta values.

    So, although those didn’t work, the one-off solutions wouldn’t have been feasible anyways for my case (there’s 400+ venues from my CSV import that are missing the Lat/Longitude values).
    With that said, is the snippet you mentioned in the following topic still valid? https://tri.be/support/forums/topic/map-view-missing-venues/
    If so, it seems that would be my best course of action to get the VenueLat and VenueLng generated for all venues that have previously been added to my database.

    Please let me know either way. Once I get the existing data fixed (which hopefully that snippet would do), I’ll then go ahead and tackle the second part of this issue…figuring out what is causing the events submitted via Community Events to not generate the VenueLat and VenueLng meta values.

    Thanks and sorry for the long post!
    Sean

    #137871
    irishrunner16
    Participant

    PS – if that snippet is what you’d suggest trying next, is it resource intensive? Wondering if should I add it to my functions.php during off-peak traffic hours and/or disable Community Events for a certain period of time while it runs? Not sure how long it would take to have those values generated for ~450 venues?

    #138674
    Barry
    Member

    You could certainly try that snippet, yes: I can’t really predict how long it would take to run unfortunately as besides how fast the actual database operations are going to be (and nothing outrageous is really happening on that front) it also hinges on querying Google via HTTP for geolocation data – and though that’s normally pretty fast it does vary quite a bit.

    If you’re able to run it at a suitably quiet time that could be best.

    #138714
    irishrunner16
    Participant

    Ok, so I tried running that snippet but it unfortunately did not create any _VenueLat or _VenueLng values for the venues that are missing those. I also tried the snippet with the default theme and only The Events Calendar plugins activated, but it still didn’t work. Finally, tried deleting VenueGeoAddress from an event and ran the snippet, which recreated the VenueGeoAddress, but still not Lat or Lng coordinates.

    What else could I do to force the creation of the VenueLat and VenueLng meta values?

    Thanks,
    Sean

    #139391
    Barry
    Member

    Hi Sean, let’s run a quick test if we can – I’m interested to know if you are receiving valid responses from Google. Can you try adding this code (temporarily – remove after this test) to your theme’s functions.php file:

    if ( isset( $_GET['testgeofetch'] ) ) add_filter( 'the_content', 'irishrunner_geotest' );
    
    function irishrunner_geotest( $content ) {
    	remove_action( 'the_content', 'irishrunner_geotest' );
    	$address = 'Station Square Academy St Inverness IV1 1LG United Kingdom';
    
    	$url = add_query_arg( array(
    			'address' => urlencode( $address ),
    			'sensor' => 'false'
    		), 'http://maps.googleapis.com/maps/api/geocode/json' );
    	$response = wp_remote_get( $url );
    
    	if ( is_wp_error( $response ) ) $result = 'Failed with error';
    	elseif ( 200 !== $response['response']['code']) $result = 'Reached Google but received a negative response';
    	else {
    		$data = json_decode( $response['body'] );
    		$geometry = (array) $data->results[0]->geometry->location;
    		$geometry = implode( ',', $geometry );
    		$result = "Coordinates: $geometry";
    	}
    
    	$highlight = 'style="background: #FE7; padding:1em; color:#502; font-weight: bold"';
    	return "<p $highlight>$result</p>$content";
    }

    Then visit a regular page (any page should do) but add a URL query at the end – like this:

    http://example.com/some-page/?testgeofetch

    In the best case you will then see something like this yellow block just below the page title:

    coordinate-output-google-geodata-test

    Can you give that a go and let me know what you see within the yellow block in your case?

    Thanks!

    #139829
    irishrunner16
    Participant

    Hi Barry,

    Before I got to your latest response, I had tried some additional testing. One test I did (as I was, and still am, thinking it might be a server related issue) was increase the php memory limit from 256m to 1500m. Initially that seemed to fix the issue, as all test events I submitted did generate the Lat and Lng values. I also tried running the snippet to force the generation of those values for the venues that are missing those. That started ok, but it eventually crashed the server (I did check the database and about 30-40 events that were missing lat/lng values did have them created before the timeout/crash). Since then, I’ve tried submitting a few more events, and the Lat/Lng values are once again not being generated.

    I was hoping the memory was the issue (although I was a bit surprised it seemed to have an effect, given that I had it at at least 256mb all along), but given how things have taken a step backwards again since trying the snippet to force the generation of lat/lng, I’m not as confident that is the source of the problem. Unless there could be another setting on the server that is overriding the higher memory limit I had put in my htaccess file?

    I just tried adding that geofetch code to my functions.php file, but I’m not seeing any block on the page. Not sure if that means it was unsuccessful or not?

    This sure is proving to be a tricky (and frustrating) one! At least the memory test did yield some changes…although I’m still not sure why it’d require such a high limit or why it seemed to work temporarily?

    Thanks again,
    Sean

    #139849
    irishrunner16
    Participant

    Tried the geofetch code on an install with no other plugins running and that got it to display, but its only showing the following:

    Coordinates:

    #139914
    irishrunner16
    Participant

    Wordpress SEO plugin was prohibiting the geofetch from displaying on my production site. Disabled that and the yellow block also only returned “Coordinates:” there as well.

Viewing 15 posts - 1 through 15 (of 21 total)
  • The topic ‘Events missing VenueLat and VenueLng meta_key values’ is closed to new replies.