How to create a 'Streak' i.e. number of daily consecutive entries?

I am attempting to create a ‘Streak’, somewhat similar to the feature available on Snapchat. The end-goal I would like to achieve is to be able to count the number of consecutive entries (within a time frame of 24 hours between each)

I am struggling to create this and would appreciate some thought-starters as to how this would be done.

Appreciate the help!

I’m sure there are many ways to go about this. Here’s one idea:

Assuming you have a list of entries held within another thing (let’s call it entry_grouping for simplicity) you can add a new custom field to entry_grouping: streak (number, default = 0)

With this you can do the following to update streak: Every time an entry is created/added to entry_grouping, run conditionals on your workflow actions prior to creating the new entry:

Less than 24 hours have elapsed since last entry was created in the current entry_grouping

When [Do a search for entry’s [parent entry_grouping = this entry’s entry_grouping] [sorted desc by date created] first item’s creation date [plus + ] 24 hours is [greater than < ] Current date/time then increase streak by 1:

(Note: query in pictures should read Search for entry’s, not entry_grouping)

More than 24 hours have elapsed since last entry was created in the current entry_grouping

When [Do a search for entry’s [parent entry_grouping = this entry’s entry_grouping] [sorted desc by date created] first item’s creation date [plus + ] 24 hours is [less than < ] Current date/time then reset streak to 0:

Update: I realized you probably don’t want the streak to go up by 1 every time a new entry is added. To address this, you can add a new field to entry_grouping: **streak_last_updated** (date) – with this, you can run an additional conditional to check if streak_last_updated + 24 hours > Current date/time. If true, then make updates to the streak count as well as the streak_last_updated date.

Update 2: I may not have given this enough thought :upside_down_face: (meaning the above may not work as expected) After playing around in Bubble and experimenting, it hit me: recurring API workflows may be your best option here instead of conditionals on their own. If I complete a working prototype matching Snapchat’s functionality I’ll share the link here.

1 Like

Hi Philip,

Thanks so much for the quick response.

I also would like this streak to be user-specific. Hence, I added an additional condition in the workflow to search for the latest entry posted by the current user.

I’ve given your initial solution a go, but it appears that the streak counter does not increase each time a new entry is posted.

Would appreciate it if you could share that recurring API workflow you mentioned.

Many thanks :slight_smile:

Hi Philip,

Have you had any luck around the Streak functionality?

Please let me know if there have been any developments!

Thank you.

This topic was automatically closed after 70 days. New replies are no longer allowed.