Adding clear old history on read, if there is nothing to do this should add very little work.

This commit is contained in:
mike12345567 2022-06-27 18:39:33 +01:00
parent da2303803c
commit a01790b837
2 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,7 @@ const {
const { events } = require("@budibase/backend-core") const { events } = require("@budibase/backend-core")
const { app } = require("@budibase/backend-core/cache") const { app } = require("@budibase/backend-core/cache")
const { logs } = require("@budibase/pro") const { logs } = require("@budibase/pro")
const { clearOldHistory } = require("../../automations/logging")
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS) const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS) const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
@ -195,6 +196,8 @@ exports.destroy = async function (ctx) {
exports.logSearch = async function (ctx) { exports.logSearch = async function (ctx) {
let { automationId, status, page, startDate } = ctx.request.body let { automationId, status, page, startDate } = ctx.request.body
// before querying logs, make sure old logs are cleared out
await clearOldHistory()
ctx.body = await logs.automations.getLogs( ctx.body = await logs.automations.getLogs(
startDate, startDate,
status, status,

View File

@ -32,7 +32,7 @@ function getStatus(results: AutomationResults) {
return status return status
} }
async function clearOldHistory() { export async function clearOldHistory() {
const db = getProdAppDB() const db = getProdAppDB()
try { try {
const expired = await logs.automations.getExpiredLogs() const expired = await logs.automations.getExpiredLogs()