Forum Academy Marketplace Showcase Pricing Features

How to show users online within past 15 minutes

I’m trying to make a social platform and I need to be able to have the main list of users show only those who are online (defined as having used the app within the past 15 minutes) but i’m completely unable to figure it out. I keep trying to play with the date data types (like online=current date +900 seconds) but it stays red.

Have any of you created an online-status workflow?

thanks

On the top of my head, you can do the following. Perform a search where the date is greater than the current date changed to -15 minutes. The search should be on a type where to store the date info, which could be on the User or specialized type. Update the data on a page load or another workflow that is ran when the user is logged in. Ideally, perform this workflow within another workflow that is already occurring so you don’t incur too many workflow runs.

1 Like

My feeling is that it would make more sense to have this separate from the User’s profile and as a list item in another database.

To do this, I would create a login/logout event and/or a page level event.

  • To flag as active: when the user logs in, add the current user to the List “Active Users.”
  • To flag as inactive: have a time-based page-level workflow (Do every 15 minutes), that removes them from the “Active Users” list
  • To flag as inactive (offline): create a workflow for when the user signs out, it removes them from the list

Upside: you can also let a user set their status as “invisible” or "visible by creating a workflow that removes or adds them from the list.

In that approach, you aren’t doing a database search for users matching the parameter. Rather, you’re displaying a list of users (which you can filter, if needed).

3 Likes

Did you do this? Did it work?

I haven’t. Just a suggested approach. Not quite pertinent to the structure of my app.

In my social app I have a repeating group always showing active users. I do this by having a date field in the Users Thing and a workflow thats runs every 30 secs that sets this field to the current time. My repeating group then searches for Users with this field containing a date not older than 30 secs. The workflow is put in the menu which is a reusable element. This way the action is performed on every page.

5 Likes

In case people are still interested in this, I created a step-by-step guide to show whether a user is online within the past 15 minutes. The Bubble editor is also available so you can copy the elements and workflows directly to your own Bubble app.