chore: bump prettier from 2.8.1 to 3.0.0 in /site (#8477)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Cian Johnston <cian@coder.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
This commit is contained in:
dependabot[bot]
2023-07-13 14:44:12 +03:00
committed by GitHub
co-authored by Cian Johnston Muhammad Atif Ali
parent 3727e02bbf
commit 24ec05b5c5
13 changed files with 97 additions and 85 deletions
+2 -2
View File
@@ -481,8 +481,8 @@ export function waitForBuild(build: TypesGen.WorkspaceBuild) {
let latestJobInfo: TypesGen.ProvisionerJob | undefined = undefined
while (
!["succeeded", "canceled"].some((status) =>
latestJobInfo?.status.includes(status),
!["succeeded", "canceled"].some(
(status) => latestJobInfo?.status.includes(status),
)
) {
const { job } = await getWorkspaceBuildByNumber(
+1 -1
View File
@@ -31,4 +31,4 @@ export const getDefaultFilterProps = <TFilterProps>({
values,
},
menus,
} as TFilterProps)
}) as TFilterProps
+7 -4
View File
@@ -262,10 +262,13 @@ const selectByLatency = (
return undefined
}
const proxyMap = proxies.reduce((acc, proxy) => {
acc[proxy.id] = proxy
return acc
}, {} as Record<string, Region>)
const proxyMap = proxies.reduce(
(acc, proxy) => {
acc[proxy.id] = proxy
return acc
},
{} as Record<string, Region>,
)
const best = Object.keys(latencies)
.map((proxyId) => {
+37 -34
View File
@@ -87,43 +87,46 @@ export const useProxyLatency = (
// proxyMap is a map of the proxy path_app_url to the proxy object.
// This is for the observer to know which requests are important to
// record.
const proxyChecks = proxies.reduce((acc, proxy) => {
// Only run the latency check on healthy proxies.
if (!proxy.healthy) {
return acc
}
// Do not run latency checks if a cached check exists below the latestFetchRequest Date.
// This prevents fetching latencies too often.
// 1. Fetch the latest stored latency for the given proxy.
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
if (storedLatencies && storedLatencies[proxy.id]) {
const fetchRequestDate = new Date(latestFetchRequest)
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
prev.at > next.at ? prev : next,
)
if (latest && latest.at > fetchRequestDate) {
// dispatch the cached latency. This latency already went through the
// guard logic below, so we can just dispatch it again directly.
dispatchProxyLatencies({
proxyID: proxy.id,
cached: true,
report: latest,
})
const proxyChecks = proxies.reduce(
(acc, proxy) => {
// Only run the latency check on healthy proxies.
if (!proxy.healthy) {
return acc
}
}
// Add a random query param to the url to make sure we don't get a cached response.
// This is important in case there is some caching layer between us and the proxy.
const url = new URL(
`/latency-check?cache_bust=${generateRandomString(6)}`,
proxy.path_app_url,
)
acc[url.toString()] = proxy
return acc
}, {} as Record<string, Region>)
// Do not run latency checks if a cached check exists below the latestFetchRequest Date.
// This prevents fetching latencies too often.
// 1. Fetch the latest stored latency for the given proxy.
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
if (storedLatencies && storedLatencies[proxy.id]) {
const fetchRequestDate = new Date(latestFetchRequest)
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
prev.at > next.at ? prev : next,
)
if (latest && latest.at > fetchRequestDate) {
// dispatch the cached latency. This latency already went through the
// guard logic below, so we can just dispatch it again directly.
dispatchProxyLatencies({
proxyID: proxy.id,
cached: true,
report: latest,
})
return acc
}
}
// Add a random query param to the url to make sure we don't get a cached response.
// This is important in case there is some caching layer between us and the proxy.
const url = new URL(
`/latency-check?cache_bust=${generateRandomString(6)}`,
proxy.path_app_url,
)
acc[url.toString()] = proxy
return acc
},
{} as Record<string, Region>,
)
// dispatchProxyLatenciesGuarded will assign the latency to the proxy
// via the reducer. But it will only do so if the performance entry is
@@ -20,7 +20,7 @@ const templatePermissions = (templateId: string) =>
},
action: "update",
},
} as const)
}) as const
const fetchTemplateSettings = async (orgId: string, name: string) => {
const template = await getTemplateByName(orgId, name)
+27 -24
View File
@@ -149,31 +149,34 @@ export const MockWorkspaceProxies: TypesGen.WorkspaceProxy[] = [
]
export const MockProxyLatencies: Record<string, ProxyLatencyReport> = {
...MockWorkspaceProxies.reduce((acc, proxy) => {
if (!proxy.healthy) {
...MockWorkspaceProxies.reduce(
(acc, proxy) => {
if (!proxy.healthy) {
return acc
}
acc[proxy.id] = {
// Make one of them inaccurate.
accurate: proxy.id !== "26e84c16-db24-4636-a62d-aa1a4232b858",
// This is a deterministic way to generate a latency to for each proxy.
// It will be the same for each run as long as the IDs don't change.
latencyMS:
(Number(
Array.from(proxy.id).reduce(
// Multiply each char code by some large prime number to increase the
// size of the number and allow use to get some decimal points.
(acc, char) => acc + char.charCodeAt(0) * 37,
0,
),
) /
// Cap at 250ms
100) %
250,
at: new Date(),
}
return acc
}
acc[proxy.id] = {
// Make one of them inaccurate.
accurate: proxy.id !== "26e84c16-db24-4636-a62d-aa1a4232b858",
// This is a deterministic way to generate a latency to for each proxy.
// It will be the same for each run as long as the IDs don't change.
latencyMS:
(Number(
Array.from(proxy.id).reduce(
// Multiply each char code by some large prime number to increase the
// size of the number and allow use to get some decimal points.
(acc, char) => acc + char.charCodeAt(0) * 37,
0,
),
) /
// Cap at 250ms
100) %
250,
at: new Date(),
}
return acc
}, {} as Record<string, ProxyLatencyReport>),
},
{} as Record<string, ProxyLatencyReport>,
),
}
export const MockBuildInfo: TypesGen.BuildInfoResponse = {
@@ -138,7 +138,7 @@ const permissionsToCheck = (
},
action: "read",
},
} as const)
}) as const
export const workspaceMachine = createMachine(
{
@@ -39,7 +39,7 @@ const permissionsToCheck = (workspace: TypesGen.Workspace) =>
},
action: "update",
},
} as const)
}) as const
export type WorkspaceScheduleEvent =
| {