правочки

This commit is contained in:
gorbenko.pavel
2026-08-17 18:11:06 +05:00
parent 34cab4d03d
commit 11811d101f
@@ -847,25 +847,37 @@ async function loadByIds(
const byKey = new Map<string, IMyRequest>(); const byKey = new Map<string, IMyRequest>();
await Promise.all( await Promise.all(
Array.from(byPartition.values()).map(async ({ type, target, ids }) => { Array.from(byPartition.values()).map(async ({ type, target, ids }) => {
const sp = spForSite(target.siteUrl, context); // Ошибку ловим НА ПАРТИЦИЮ, а не на весь вызов: список серии может быть
const list = sp.web.getList(target.listId); // недоступен (удалён, переименован, остался в реестре после смены списка у
// типа заявки) — SharePoint отвечает 404 «Файл не найден». Без изоляции
// один такой список валил бы ВСЮ выдачу «Моих заявок», и пользователь не
// увидел бы ничего вместо «всё, кроме одного архива».
try {
const sp = spForSite(target.siteUrl, context);
const list = sp.web.getList(target.listId);
await Promise.all( await Promise.all(
chunk(ids, REST_ID_FILTER_CHUNK).map(async (idsChunk) => { chunk(ids, REST_ID_FILTER_CHUNK).map(async (idsChunk) => {
const rows = (await list.items const rows = (await list.items
.filter(idsChunk.map((id) => `Id eq ${id}`).join(' or ')) .filter(idsChunk.map((id) => `Id eq ${id}`).join(' or '))
.select('Id', 'Title', 'RequestStatus', 'Created', 'Author/EMail', 'Author/Title') .select('Id', 'Title', 'RequestStatus', 'Created', 'Author/EMail', 'Author/Title')
.expand('Author') .expand('Author')
.top(idsChunk.length)()) as Array<Record<string, unknown>>; .top(idsChunk.length)()) as Array<Record<string, unknown>>;
rows.forEach((r) => { rows.forEach((r) => {
const author = r.Author as { EMail?: string; Title?: string } | undefined; const author = r.Author as { EMail?: string; Title?: string } | undefined;
byKey.set( byKey.set(
requestKey(target.listId, r.Id as number), requestKey(target.listId, r.Id as number),
toMyRequest(r, author, type, kind, target) toMyRequest(r, author, type, kind, target)
); );
}); });
}) })
); );
} catch (e) {
console.error(
`[Текущие заявки] «${type.name}»: не удалось прочитать список ${target.listId} — заявки из него в выдачу не попадут:`,
(e as Error).message
);
}
}) })
); );
return byKey; return byKey;