fix: Logs were being displayed in the wrong order

This commit is contained in:
jamesread 2025-11-11 23:32:00 +00:00
parent b97dd23abb
commit 5b57cf2480
2 changed files with 21 additions and 11 deletions

View File

@ -81,13 +81,21 @@ const totalCount = ref(0)
const { t } = useI18n() const { t } = useI18n()
const filteredLogs = computed(() => { const filteredLogs = computed(() => {
if (!searchText.value) { let result = logs.value
return logs.value
} if (searchText.value) {
const searchLower = searchText.value.toLowerCase() const searchLower = searchText.value.toLowerCase()
return logs.value.filter(log => result = logs.value.filter(log =>
log.actionTitle.toLowerCase().includes(searchLower) log.actionTitle.toLowerCase().includes(searchLower)
) )
}
// Sort by timestamp with most recent first
return [...result].sort((a, b) => {
const dateA = a.datetimeStarted ? new Date(a.datetimeStarted).getTime() : 0
const dateB = b.datetimeStarted ? new Date(b.datetimeStarted).getTime() : 0
return dateB - dateA // Descending order (most recent first)
})
}) })
async function fetchLogs() { async function fetchLogs() {

View File

@ -237,11 +237,14 @@ func isLogEntryAllowedByACL(cfg *config.Config, user *acl.AuthenticatedUser, ent
// filterLogsByACL builds a filtered list of logs in reverse-chronological order // filterLogsByACL builds a filtered list of logs in reverse-chronological order
// that are visible to the user based on ACL rules. // that are visible to the user based on ACL rules.
func (e *Executor) filterLogsByACL(cfg *config.Config, user *acl.AuthenticatedUser) []*InternalLogEntry { func (e *Executor) filterLogsByACL(cfg *config.Config, user *acl.AuthenticatedUser) []*InternalLogEntry {
filtered := make([]*InternalLogEntry, 0)
e.logmutex.RLock() e.logmutex.RLock()
for i := len(e.logsTrackingIdsByDate) - 1; i >= 0; i-- { defer e.logmutex.RUnlock()
entry := e.logs[e.logsTrackingIdsByDate[i]]
filtered := make([]*InternalLogEntry, 0, len(e.logsTrackingIdsByDate))
for _, trackingId := range e.logsTrackingIdsByDate {
entry := e.logs[trackingId]
if !isValidLogEntryForACL(entry) { if !isValidLogEntryForACL(entry) {
continue continue
} }
@ -249,7 +252,6 @@ func (e *Executor) filterLogsByACL(cfg *config.Config, user *acl.AuthenticatedUs
filtered = append(filtered, entry) filtered = append(filtered, entry)
} }
} }
e.logmutex.RUnlock()
return filtered return filtered
} }