fix: Map page finish

This commit is contained in:
2025-06-13 09:17:24 +03:00
parent 300ff262ce
commit f49caf3ec8
2 changed files with 504 additions and 484 deletions

File diff suppressed because it is too large Load Diff

View File

@ -54,10 +54,17 @@ class MapStore {
sights: ApiSight[] = [];
getRoutes = async () => {
// ИСПРАВЛЕНО: Проблема N+1.
// Вместо цикла и множества запросов теперь выполняется один.
// Бэкенд по эндпоинту `/route` должен возвращать массив полных объектов маршрутов.
const response = await languageInstance("ru").get("/route");
console.log(response.data);
const routesIds = response.data.map((route: any) => route.id);
for (const id of routesIds) {
const route = await languageInstance("ru").get(`/route/${id}`);
this.routes.push({
id: route.data.id,
route_number: route.data.route_number,
path: route.data.path,
});
}
const mappedRoutes: ApiRoute[] = response.data.map((route: any) => ({
id: route.id,
route_number: route.route_number,