[PR #4441] POC: Add LastSeenManager to batch user activity updates #4252

Open
opened 2026-04-25 00:19:00 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4441
Author: @Vito0912
Created: 6/28/2025
Status: 🔄 Open

Base: masterHead: feat/lastSeen


📝 Commits (1)

  • 0749a55 POC: Add LastSeenManager to batch user activity updates

📊 Changes

3 files changed (+144 additions, -4 deletions)

View changed files

📝 server/Server.js (+25 -1)
📝 server/SocketAuthority.js (+5 -3)
server/managers/LastSeenManager.js (+114 -0)

📄 Description

Brief summary

This pull request introduces a new LastSeenManager to handle user activity tracking and periodic updates to the lastSeen timestamp in the database without just relying on the socket. The changes integrate this manager into the server's lifecycle.

Which issue is fixed?

N/A

In-depth Description

Collects users into a Set, flushes every 5 minutes, and sets the timestamp. This is not very accurate (it can be up to 5 minutes off), but it should be the most efficient solution. It might be okay to add the real timestamp, but I think it is not necessary. When authentication happens, the time is updated accurately. So we just add a estimate and do not change the current behaviour

How have you tested this?

My own server

Screenshots

N/A


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/4441 **Author:** [@Vito0912](https://github.com/Vito0912) **Created:** 6/28/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `feat/lastSeen` --- ### 📝 Commits (1) - [`0749a55`](https://github.com/advplyr/audiobookshelf/commit/0749a55deb26dbd9417f8b8e0fa1ed4235550a92) POC: Add LastSeenManager to batch user activity updates ### 📊 Changes **3 files changed** (+144 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `server/Server.js` (+25 -1) 📝 `server/SocketAuthority.js` (+5 -3) ➕ `server/managers/LastSeenManager.js` (+114 -0) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary This pull request introduces a new `LastSeenManager` to handle user activity tracking and periodic updates to the `lastSeen` timestamp in the database without just relying on the socket. The changes integrate this manager into the server's lifecycle. ## Which issue is fixed? N/A ## In-depth Description Collects users into a Set, flushes every 5 minutes, and sets the timestamp. This is not very accurate (it can be up to 5 minutes off), but it should be the most efficient solution. It might be okay to add the real timestamp, but I think it is not necessary. When authentication happens, the time is updated accurately. So we just add a estimate and do not change the current behaviour ## How have you tested this? My own server ## Screenshots N/A --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:00 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4252