1
0
Fork 0
mirror of synced 2024-10-04 12:03:31 +13:00

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 { doWithDB, DocumentType } from "../db"
import { Database, App } from "@budibase/types" import { Database, App } from "@budibase/types"
const AppState = { export enum AppState {
INVALID: "invalid", INVALID = "invalid",
} }
export interface DeletedApp {
state: AppState
}
const EXPIRY_SECONDS = 3600 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. * @param {string} appId the id of the app to get metadata from.
* @returns {object} the app metadata. * @returns {object} the app metadata.
*/ */
export async function getAppMetadata(appId: string) { export async function getAppMetadata(appId: string): Promise<App | DeletedApp> {
const client = await getAppClient() const client = await getAppClient()
// try cache // try cache
let metadata = await client.get(appId) let metadata = await client.get(appId)
@ -61,11 +66,8 @@ export async function getAppMetadata(appId: string) {
} }
await client.store(appId, metadata, expiry) 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)) { return metadata
throw { status: 404, message: "No app metadata found" }
}
return metadata as App
} }
/** /**

View file

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

View file

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

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