Merge mobile AI and operating query fixes into main
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -72,6 +72,17 @@ test('preserves display, inventory and macro region mappings', () => {
|
||||
assert.equal(resolveCity(null, '[上海市]'), '上海市');
|
||||
});
|
||||
|
||||
test('municipality districts resolve to the city used by filters and grouping', () => {
|
||||
for (const [province, district] of [['上海', '松江区'], ['北京', '朝阳区'], ['天津', '滨海新区'], ['重庆', '渝北区']]) {
|
||||
assert.equal(resolveCity(district, province), `${province}市`);
|
||||
assert.equal(resolveCity(`[${district}]`, `[${province}市]`), `${province}市`);
|
||||
assert.equal(resolveCity(province, null), `${province}市`);
|
||||
}
|
||||
assert.equal(resolveCity('杭州市', '浙江省'), '杭州市');
|
||||
assert.equal(resolveCity('朝阳区', null), '朝阳区');
|
||||
assert.equal(resolveCity(null, null), '其他');
|
||||
});
|
||||
|
||||
test('keeps vehicle status precedence and ownership aliases', () => {
|
||||
assert.equal(mapStatus('2', '4'), 'Pending');
|
||||
assert.equal(mapStatus('1', '14'), 'Abnormal');
|
||||
|
||||
@@ -98,8 +98,12 @@ export function mapOwnership(rentStatusLabel: string | null): string {
|
||||
|
||||
export function resolveCity(city: string | null, province: string | null): string {
|
||||
const cityName = (city || '').replace(/[\[\]]/g, '').trim();
|
||||
if (cityName) return cityName;
|
||||
const provinceName = (province || '').replace(/[\[\]]/g, '').trim();
|
||||
// Location feeds put municipality districts (e.g. 松江区) in city.
|
||||
// Aggregate them under the municipality, consistently with city filters.
|
||||
const municipality = [provinceName, cityName].find(name => /^(北京|上海|天津|重庆)市?$/.test(name));
|
||||
if (municipality) return municipality.replace(/市?$/, '市');
|
||||
if (cityName) return cityName;
|
||||
return provinceName || '其他';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user