1
0
Fork 0
mirror of synced 2024-07-13 02:05:54 +12:00

Adding a minimum time to the app migration screen and adding a link to documentation.

This commit is contained in:
mike12345567 2024-06-13 17:49:41 +01:00
parent 1e34411d66
commit 8970705b39
2 changed files with 16 additions and 8 deletions

View file

@ -1,18 +1,22 @@
<script> <script>
export let isMigrationDone export let isMigrationDone
export let onMigrationDone export let onMigrationDone
export let timeoutSeconds = 10 // 3 minutes export let timeoutSeconds = 60 // 1 minute
export let minTimeSeconds = 3
const loadTime = Date.now() const loadTime = Date.now()
const intervalMs = 1000
let timedOut = false let timedOut = false
let secondsWaited = 0
async function checkMigrationsFinished() { async function checkMigrationsFinished() {
setTimeout(async () => { setTimeout(async () => {
const isMigrated = await isMigrationDone() const isMigrated = await isMigrationDone()
const timeoutMs = timeoutSeconds * 1000 const timeoutMs = timeoutSeconds * 1000
if (!isMigrated) { if (!isMigrated || secondsWaited <= minTimeSeconds) {
if (loadTime + timeoutMs > Date.now()) { if (loadTime + timeoutMs > Date.now()) {
secondsWaited += 1
return checkMigrationsFinished() return checkMigrationsFinished()
} }
@ -20,7 +24,7 @@
} }
onMigrationDone() onMigrationDone()
}, 1000) }, intervalMs)
} }
checkMigrationsFinished() checkMigrationsFinished()
@ -41,6 +45,11 @@
<span class="subtext"> <span class="subtext">
{#if !timedOut} {#if !timedOut}
Please wait and we will be back in a second! Please wait and we will be back in a second!
<br />
Checkout the
<a href="https://docs.budibase.com/docs/app-migrations" target="_blank"
>documentation</a
> on app migrations.
{:else} {:else}
An error occurred, please try again later. An error occurred, please try again later.
<br /> <br />

View file

@ -23,16 +23,15 @@ const getCacheKey = (appId: string) => `appmigrations_${env.VERSION}_${appId}`
export async function getAppMigrationVersion(appId: string): Promise<string> { export async function getAppMigrationVersion(appId: string): Promise<string> {
const cacheKey = getCacheKey(appId) const cacheKey = getCacheKey(appId)
let metadata: AppMigrationDoc | undefined = await cache.get(cacheKey) let version: string | undefined = await cache.get(cacheKey)
// returned cached version if we found one // returned cached version if we found one
if (metadata?.version) { if (version) {
return metadata.version return version
} }
let version
try { try {
metadata = await getFromDB(appId) const metadata = await getFromDB(appId)
version = metadata.version || "" version = metadata.version || ""
} catch (err: any) { } catch (err: any) {
if (err.status !== 404) { if (err.status !== 404) {