Merge pull request #11302 from Budibase/fix/bb-alerts

demote some app metadata related bb-alert messages
This commit is contained in:
Martin McKeaveney 2023-07-23 16:27:34 +01:00 committed by GitHub
commit a3eb27277f
4 changed files with 20 additions and 13 deletions

View File

@ -2,9 +2,14 @@ import { getAppClient } from "../redis/init"
import { doWithDB, DocumentType } from "../db"
import { Database, App } from "@budibase/types"
const AppState = {
INVALID: "invalid",
export enum AppState {
INVALID = "invalid",
}
export interface DeletedApp {
state: AppState
}
const EXPIRY_SECONDS = 3600
/**
@ -31,7 +36,7 @@ function isInvalid(metadata?: { state: string }) {
* @param {string} appId the id of the app to get metadata from.
* @returns {object} the app metadata.
*/
export async function getAppMetadata(appId: string) {
export async function getAppMetadata(appId: string): Promise<App | DeletedApp> {
const client = await getAppClient()
// try cache
let metadata = await client.get(appId)
@ -61,11 +66,8 @@ export async function getAppMetadata(appId: string) {
}
await client.store(appId, metadata, expiry)
}
// we've stored in the cache an object to tell us that it is currently invalid
if (isInvalid(metadata)) {
throw { status: 404, message: "No app metadata found" }
}
return metadata as App
return metadata
}
/**

View File

@ -2,7 +2,7 @@ import env from "../environment"
import { DEFAULT_TENANT_ID, SEPARATOR, DocumentType } from "../constants"
import { getTenantId, getGlobalDBName } from "../context"
import { doWithDB, directCouchAllDbs } from "./db"
import { getAppMetadata } from "../cache/appMetadata"
import { AppState, DeletedApp, getAppMetadata } from "../cache/appMetadata"
import { isDevApp, isDevAppID, getProdAppID } from "../docIds/conversions"
import { App, Database } from "@budibase/types"
import { getStartEndKeyURL } from "../docIds"
@ -101,7 +101,9 @@ export async function getAllApps({
const response = await Promise.allSettled(appPromises)
const apps = response
.filter(
(result: any) => result.status === "fulfilled" && result.value != null
(result: any) =>
result.status === "fulfilled" &&
result.value?.state !== AppState.INVALID
)
.map(({ value }: any) => value)
if (!all) {
@ -126,7 +128,11 @@ export async function getAppsByIDs(appIds: string[]) {
)
// have to list the apps which exist, some may have been deleted
return settled
.filter(promise => promise.status === "fulfilled")
.filter(
promise =>
promise.status === "fulfilled" &&
(promise.value as DeletedApp).state !== AppState.INVALID
)
.map(promise => (promise as PromiseFulfilledResult<App>).value)
}

View File

@ -44,7 +44,6 @@
let fileInput
let error = null
let fileName = null
let fileType = null
let loading = false
let validation = {}
let validateHash = ""

@ -1 +1 @@
Subproject commit 4d9840700e7684581c39965b7cb6a2b2428c477c
Subproject commit fecebc4adcc7353810c585195026c29f85db6c10