Making WordPress.org

Changeset 10554


Ignore:
Timestamp:
01/07/2021 04:29:54 AM (4 years ago)
Author:
dd32
Message:

Events API: When determining a location, preference non-alternate names and populated areas over alternate names / unpopulated locations.

Fixes #5562.

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

    r10550 r10554  
    11<?php
    2 
    32namespace Dotorg\API\Events;
    43use stdClass;
     
    356355    global $wpdb;
    357356    // Look for a location that matches the name.
     357    // The asc ordering provides preference to the oreferred name of the locations.
     358    // The population ordering provides preference to the populated areas over unpopulated/unknown.
    358359    // The FIELD() orderings give preference to rows that match the country and/or timezone, without excluding rows that don't match.
    359     // And we sort by population desc, assuming that the biggest matching location is the most likely one.
     360    // And we sort by population desc, assuming that the biggest matching location is the most likely one within the above matching groups.
    360361
    361362    // Exact match
     
    365366        WHERE name = %s
    366367        ORDER BY
     368            alt ASC,
     369            population > 0 DESC,
    367370            FIELD( %s, country  ) DESC,
    368371            FIELD( %s, timezone ) DESC,
     
    387390            WHERE name LIKE %s
    388391            ORDER BY
     392                alt ASC,
     393                population > 0 DESC,
    389394                FIELD( %s, country  ) DESC,
    390395                FIELD( %s, timezone ) DESC,
  • sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index-phpunit.php

    r10553 r10554  
    594594                'expected' => array(
    595595                    'description' => 'ciudad de méxico',
    596                     'latitude'    => '19.428',
    597                     'longitude'   => '-99.128',
     596                    'latitude'    => '19.283',
     597                    'longitude'   => '-99.133',
    598598                    'country'     => 'MX',
    599599                ),
Note: See TracChangeset for help on using the changeset viewer.