Changeset 12936
- Timestamp:
- 10/06/2023 10:27:46 PM (3 years ago)
- Location:
- sites/trunk/api.wordpress.org/public_html/events/1.0
- Files:
-
- 2 edited
-
index.php (modified) (2 diffs)
-
tests/test-index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r12352 r12936 391 391 global $wpdb; 392 392 // 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. 394 394 // 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 395 397 // The FIELD() orderings give preference to rows that match the country and/or timezone, without excluding rows that don't match. 396 398 // And we sort by population desc, assuming that the biggest matching location is the most likely one within the above matching groups. … … 404 406 FIELD( %s, country ) DESC, 405 407 alt ASC, 406 population > 0 DESC,408 population > 500 DESC, 407 409 FIELD( %s, timezone ) DESC, 408 410 LEFT( type, 1 ) = "P" DESC, -
sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php
r12258 r12936 1077 1077 ), 1078 1078 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 1079 1126 /* 1080 1127 * 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.