web/admin: fix ldap sync status for new API

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-17 16:46:18 +02:00
parent b775e7f4d3
commit 763d3ae76a
1 changed files with 13 additions and 11 deletions

View File

@ -38,19 +38,21 @@ export class LDAPSyncStatusChart extends AKChart<LDAPSyncStats> {
await Promise.all(
sources.results.map(async (element) => {
try {
const health = await api.sourcesLdapSyncStatusRetrieve({
const health = await api.sourcesLdapSyncStatusList({
slug: element.slug,
});
if (health.status !== StatusEnum.Successful) {
failed += 1;
}
const now = new Date().getTime();
const maxDelta = 3600000; // 1 hour
if (!health || now - health.taskFinishTimestamp.getTime() > maxDelta) {
unsynced += 1;
} else {
healthy += 1;
}
health.forEach(task => {
if (task.status !== StatusEnum.Successful) {
failed += 1;
}
const now = new Date().getTime();
const maxDelta = 3600000; // 1 hour
if (!health || now - task.taskFinishTimestamp.getTime() > maxDelta) {
unsynced += 1;
} else {
healthy += 1;
}
})
} catch {
unsynced += 1;
}