правочки
This commit is contained in:
@@ -847,25 +847,37 @@ async function loadByIds(
|
||||
const byKey = new Map<string, IMyRequest>();
|
||||
await Promise.all(
|
||||
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(
|
||||
chunk(ids, REST_ID_FILTER_CHUNK).map(async (idsChunk) => {
|
||||
const rows = (await list.items
|
||||
.filter(idsChunk.map((id) => `Id eq ${id}`).join(' or '))
|
||||
.select('Id', 'Title', 'RequestStatus', 'Created', 'Author/EMail', 'Author/Title')
|
||||
.expand('Author')
|
||||
.top(idsChunk.length)()) as Array<Record<string, unknown>>;
|
||||
rows.forEach((r) => {
|
||||
const author = r.Author as { EMail?: string; Title?: string } | undefined;
|
||||
byKey.set(
|
||||
requestKey(target.listId, r.Id as number),
|
||||
toMyRequest(r, author, type, kind, target)
|
||||
);
|
||||
});
|
||||
})
|
||||
);
|
||||
await Promise.all(
|
||||
chunk(ids, REST_ID_FILTER_CHUNK).map(async (idsChunk) => {
|
||||
const rows = (await list.items
|
||||
.filter(idsChunk.map((id) => `Id eq ${id}`).join(' or '))
|
||||
.select('Id', 'Title', 'RequestStatus', 'Created', 'Author/EMail', 'Author/Title')
|
||||
.expand('Author')
|
||||
.top(idsChunk.length)()) as Array<Record<string, unknown>>;
|
||||
rows.forEach((r) => {
|
||||
const author = r.Author as { EMail?: string; Title?: string } | undefined;
|
||||
byKey.set(
|
||||
requestKey(target.listId, r.Id as number),
|
||||
toMyRequest(r, author, type, kind, target)
|
||||
);
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`[Текущие заявки] «${type.name}»: не удалось прочитать список ${target.listId} — заявки из него в выдачу не попадут:`,
|
||||
(e as Error).message
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
return byKey;
|
||||
|
||||
Reference in New Issue
Block a user