mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-03 09:57:24 +02:00
use the logs maxDays before firing the goroutine
This commit is contained in:
parent
7d6b12a4ef
commit
1aff89f377
@ -287,8 +287,10 @@ func ActivityLogger(app core.App) echo.MiddlewareFunc {
|
|||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
err := next(c)
|
err := next(c)
|
||||||
|
|
||||||
|
logsMaxDays := app.Settings().Logs.MaxDays
|
||||||
|
|
||||||
// no logs retention
|
// no logs retention
|
||||||
if app.Settings().Logs.MaxDays == 0 {
|
if logsMaxDays == 0 {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,8 +350,8 @@ func ActivityLogger(app core.App) echo.MiddlewareFunc {
|
|||||||
lastLogsDeletedAt := cast.ToTime(app.Cache().Get("lastLogsDeletedAt"))
|
lastLogsDeletedAt := cast.ToTime(app.Cache().Get("lastLogsDeletedAt"))
|
||||||
daysDiff := now.Sub(lastLogsDeletedAt).Hours() * 24
|
daysDiff := now.Sub(lastLogsDeletedAt).Hours() * 24
|
||||||
|
|
||||||
if daysDiff > float64(app.Settings().Logs.MaxDays) {
|
if daysDiff > float64(logsMaxDays) {
|
||||||
deleteErr := app.LogsDao().DeleteOldRequests(now.AddDate(0, 0, -1*app.Settings().Logs.MaxDays))
|
deleteErr := app.LogsDao().DeleteOldRequests(now.AddDate(0, 0, -1*logsMaxDays))
|
||||||
if deleteErr == nil {
|
if deleteErr == nil {
|
||||||
app.Cache().Set("lastLogsDeletedAt", now)
|
app.Cache().Set("lastLogsDeletedAt", now)
|
||||||
} else if app.IsDebug() {
|
} else if app.IsDebug() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user