Making WordPress.org

Changeset 12936


Ignore:
Timestamp:
10/06/2023 10:27:46 PM (8 months ago)
Author:
iandunn
Message:

Events: Only search Geonames for places with populations > 500

This ensures that searching for Genova will find the populated city with events, rather than the small village with no events.

It seems unlikely that they'll be a meetup in town with < 500, but we can revisit this if we run into that. The smallest place I saw with a meetup had a population of around 6,000.

Location:
sites/trunk/api.wordpress.org/public_html/events/1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/events/1.0/index.php

    r12352 r12936  
    391391    global $wpdb;
    392392    // Look for a location that matches the name.
    393     // The asc ordering provides preference to the oreferred name of the locations.
     393    // The asc ordering provides preference to the preferred name of the locations.
    394394    // The population ordering provides preference to the populated areas over unpopulated/unknown.
     395    //    It's unlikely an area with less than ~500 people would hold an event, but sometimes those places rank
     396    //    higher than populated areas due to the alt vs primary name. See `Genova` unit tests
    395397    // The FIELD() orderings give preference to rows that match the country and/or timezone, without excluding rows that don't match.
    396398    // And we sort by population desc, assuming that the biggest matching location is the most likely one within the above matching groups.
     
    404406            FIELD( %s, country ) DESC,
    405407            alt ASC,
    406             population > 0 DESC,
     408            population > 500 DESC,
    407409            FIELD( %s, timezone ) DESC,
    408410            LEFT( type, 1 ) = "P" DESC,
  • sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php

    r12258 r12936  
    10771077            ),
    10781078
     1079            // Genova, IT is the native name of a populated city, and it's English name is Genoa. There's also a
     1080            // small village in IT whose English name is Genova. Geonames considers the English name to be the
     1081            // primary one, and native names are considered alternate names. We rank primary names higher than
     1082            // alternate names, and that usually works, but in this case people are more likely to be looking for
     1083            // the city.
     1084            'rural-match-less-likely-than-city-match' => array(
     1085                'input' => array(
     1086                    'location_name' => 'Genova',
     1087                    'locale'        => 'it_IT',
     1088                    'timezone'      => 'Europe/Rome',
     1089                ),
     1090                'expected' => array(
     1091                    'description' => 'genova',
     1092                    'latitude'    => '44.413',
     1093                    'longitude'   => '8.957',
     1094                    'country'     => 'IT',
     1095                ),
     1096            ),
     1097
     1098            'rural-match-less-likely-than-city-match-with-accent' => array(
     1099                'input' => array(
     1100                    'location_name' => 'Gènova',
     1101                    'locale'        => 'it_IT',
     1102                    'timezone'      => 'Europe/Rome',
     1103                ),
     1104                'expected' => array(
     1105                    'description' => 'genova',
     1106                    'latitude'    => '44.413',
     1107                    'longitude'   => '8.957',
     1108                    'country'     => 'IT',
     1109                ),
     1110            ),
     1111
     1112            'city-match-more-likely-than-rural-match' => array(
     1113                'input' => array(
     1114                    'location_name' => 'Genoa',
     1115                    'locale'        => 'it_IT',
     1116                    'timezone'      => 'Europe/Rome',
     1117                ),
     1118                'expected' => array(
     1119                    'description' => 'genoa',
     1120                    'latitude'    => '44.405',
     1121                    'longitude'   => '8.944',
     1122                    'country'     => 'IT',
     1123                ),
     1124            ),
     1125
    10791126            /*
    10801127             * A combination of city, region, and country are given, along with the locale and timezone
Note: See TracChangeset for help on using the changeset viewer.