Snelheid
This commit is contained in:
@@ -343,7 +343,7 @@ function jira_fetch_project_statuses(string $domain, string $email, string $apiT
|
||||
|
||||
$cacheKey = "jira_proj_statuses_" . $pKey . "_" . md5($cleanDomain);
|
||||
$cached = fociz_cache_get($cacheKey);
|
||||
if (is_array($cached) && !empty($cached)) {
|
||||
if ($cached !== null && is_array($cached)) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ function jira_fetch_project_statuses(string $domain, string $email, string $apiT
|
||||
'Authorization' => $authHeader,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'timeout' => 8,
|
||||
'timeout' => 4,
|
||||
]);
|
||||
|
||||
if ($response['status'] === 404 || $response['status'] === 405) {
|
||||
@@ -367,7 +367,7 @@ function jira_fetch_project_statuses(string $domain, string $email, string $apiT
|
||||
'Authorization' => $authHeader,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'timeout' => 8,
|
||||
'timeout' => 4,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ function jira_fetch_project_statuses(string $domain, string $email, string $apiT
|
||||
|
||||
fociz_cache_set($cacheKey, $statuses, 86400); // 24 uur cache
|
||||
} else {
|
||||
fociz_cache_set($cacheKey, [], 1800); // 30 min negatieve cache
|
||||
fociz_cache_set($cacheKey, [], 86400); // 24 uur negatieve cache zodat ontbrekende projecten niet herhaaldelijk vertragen
|
||||
}
|
||||
|
||||
return $statuses;
|
||||
@@ -471,7 +471,7 @@ function jira_fetch_issues(string $domain, string $email, string $apiToken, stri
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'body' => $payload,
|
||||
'timeout' => 12,
|
||||
'timeout' => 6,
|
||||
]);
|
||||
|
||||
if ($response['status'] === 405 || $response['status'] === 400) {
|
||||
@@ -500,7 +500,7 @@ function jira_fetch_issues(string $domain, string $email, string $apiToken, stri
|
||||
'Authorization' => $authHeader,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'timeout' => 12,
|
||||
'timeout' => 6,
|
||||
]);
|
||||
|
||||
if ($response['status'] === 404) {
|
||||
@@ -513,9 +513,13 @@ function jira_fetch_issues(string $domain, string $email, string $apiToken, stri
|
||||
$getParams = [
|
||||
'jql' => $jql,
|
||||
'maxResults' => $currentPageSize,
|
||||
'startAt' => $startAt,
|
||||
'fields' => implode(',', $fieldsList),
|
||||
];
|
||||
if (!empty($nextPageToken)) {
|
||||
$getParams['nextPageToken'] = $nextPageToken;
|
||||
} elseif ($startAt > 0) {
|
||||
$getParams['startAt'] = $startAt;
|
||||
}
|
||||
$urlV2 = $cleanDomain . '/rest/api/2/search?' . http_build_query($getParams);
|
||||
$response = fociz_http_request($urlV2, [
|
||||
'method' => 'GET',
|
||||
@@ -523,7 +527,7 @@ function jira_fetch_issues(string $domain, string $email, string $apiToken, stri
|
||||
'Authorization' => $authHeader,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'timeout' => 12,
|
||||
'timeout' => 6,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1238,6 +1242,11 @@ function jira_get_dashboard_data(int $userId, bool $forceRefresh = false): array
|
||||
$availableStatuses = jira_fetch_statuses($domain, $email, $apiToken);
|
||||
|
||||
if (!$assignedRes['success'] && !$teamRes['success']) {
|
||||
// Val terug op bestaande cache snapshot indien live request faalt
|
||||
$fallback = fociz_cache_get($cacheKey);
|
||||
if ($fallback && is_array($fallback)) {
|
||||
return array_merge($fallback, ['from_cache' => true, 'warning' => 'Kon Jira niet actueel bijwerken; tonen opgeslagen snapshot.']);
|
||||
}
|
||||
return [
|
||||
'is_demo' => false,
|
||||
'success' => false,
|
||||
@@ -1250,17 +1259,10 @@ function jira_get_dashboard_data(int $userId, bool $forceRefresh = false): array
|
||||
$assignedIssues = $assignedRes['success'] ? $assignedRes['issues'] : [];
|
||||
$teamIssues = $teamRes['success'] ? $teamRes['issues'] : [];
|
||||
|
||||
// Project-specifieke statussen ophalen voor gebruikte projecten
|
||||
$activeProjKeys = ['SD', 'IN', 'AAN', 'GEN'];
|
||||
$allLoaded = array_merge($assignedIssues, $teamIssues);
|
||||
foreach ($allLoaded as $iss) {
|
||||
$pk = strtoupper(trim($iss['project_key'] ?? ''));
|
||||
if (!empty($pk) && !in_array($pk, $activeProjKeys, true)) {
|
||||
$activeProjKeys[] = $pk;
|
||||
}
|
||||
}
|
||||
// Projectstatussen: haal uitsluitend het actieve hoofdproject op om sequentiële HTTP latency te elimineren
|
||||
$projectStatusesMap = [];
|
||||
foreach ($activeProjKeys as $pk) {
|
||||
$targetProjects = ['SD'];
|
||||
foreach ($targetProjects as $pk) {
|
||||
$pStats = jira_fetch_project_statuses($domain, $email, $apiToken, $pk);
|
||||
if (!empty($pStats)) {
|
||||
$projectStatusesMap[$pk] = $pStats;
|
||||
@@ -1283,7 +1285,7 @@ function jira_get_dashboard_data(int $userId, bool $forceRefresh = false): array
|
||||
'project_statuses' => $projectStatusesMap,
|
||||
];
|
||||
|
||||
fociz_cache_set($cacheKey, $data, 180); // 3 minuten cache
|
||||
fociz_cache_set($cacheKey, $data, 900); // 15 minuten cache voor supersnelle paginaladingen
|
||||
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
$_SESSION[$cacheKey] = [
|
||||
|
||||
@@ -330,7 +330,7 @@ function microsoft_fetch_events_range(int $userId, string $startDate, string $en
|
||||
'Accept' => 'application/json',
|
||||
'Prefer' => 'outlook.timezone="Europe/Amsterdam"',
|
||||
],
|
||||
'timeout' => 12,
|
||||
'timeout' => 6,
|
||||
]);
|
||||
|
||||
// Retry bij 401 Unauthorized
|
||||
@@ -345,7 +345,7 @@ function microsoft_fetch_events_range(int $userId, string $startDate, string $en
|
||||
'Accept' => 'application/json',
|
||||
'Prefer' => 'outlook.timezone="Europe/Amsterdam"',
|
||||
],
|
||||
'timeout' => 12,
|
||||
'timeout' => 6,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ function microsoft_fetch_events_range(int $userId, string $startDate, string $en
|
||||
];
|
||||
}
|
||||
|
||||
fociz_cache_set($cacheKey, $events, 60);
|
||||
fociz_cache_set($cacheKey, $events, 300); // 5 minuten cache
|
||||
return $events;
|
||||
}
|
||||
|
||||
@@ -1567,7 +1567,7 @@ function microsoft_fetch_folder_messages(int $userId, string $folderId = 'inbox'
|
||||
'Accept' => 'application/json',
|
||||
'Prefer' => 'outlook.body-content-type="text"',
|
||||
],
|
||||
'timeout' => 15,
|
||||
'timeout' => 6,
|
||||
]);
|
||||
|
||||
if ($res['status'] !== 200 || !isset($res['json']['value'])) {
|
||||
|
||||
Reference in New Issue
Block a user