feat: improve operations diagnostics and channel management
This commit is contained in:
@@ -111,6 +111,27 @@ export class DictionariesService {
|
||||
@Optional() private readonly phoneRoutingLookup?: PhoneRoutingLookupService,
|
||||
) {}
|
||||
|
||||
async listAdministrativeRegions() {
|
||||
const rows = await this.prisma.phoneSegment.findMany({
|
||||
where: { province: { not: null } },
|
||||
select: { province: true, city: true },
|
||||
distinct: ['province', 'city'],
|
||||
});
|
||||
const citiesByProvince = new Map<string, Set<string>>();
|
||||
for (const row of rows) {
|
||||
const province = row.province?.trim();
|
||||
if (!province) continue;
|
||||
const cities = citiesByProvince.get(province) ?? new Set<string>();
|
||||
const city = row.city?.trim();
|
||||
if (city) cities.add(city);
|
||||
citiesByProvince.set(province, cities);
|
||||
}
|
||||
return Array.from(citiesByProvince, ([province, cities]) => ({
|
||||
province,
|
||||
cities: Array.from(cities).sort((left, right) => left.localeCompare(right, 'zh-CN')),
|
||||
})).sort((left, right) => left.province.localeCompare(right.province, 'zh-CN'));
|
||||
}
|
||||
|
||||
async listPhoneSegments(query: PhoneSegmentListQuery = {}) {
|
||||
const page = Math.max(1, Number(query.page ?? 1));
|
||||
const pageSize = Math.min(100, Math.max(1, Number(query.pageSize ?? 25)));
|
||||
|
||||
Reference in New Issue
Block a user