Current Streak, Best streak logic help (I have a few ideas already...)

There’s a couple of threads that talk about creating user streaks, but none that seem conclusive. Would love to put this topic to an end and figure it out with you guys once and for all! WOO!

So streaks are consecutive days that someone does something, be it a workout, a meditation, etc…

Here’s how I’ve been thinking about it, though I don’t know how to put it together:

Streak logic
After action is completed:
+1 streak count

reset to 0 if no action completed yesterday… (seems like this would have to be a daily check at midnight. I need help in setting this recurring workflow up, too)

So something like: action completed date is < current date - 1 day (sec, min, hour set to 0) ?

How would you set this up?

Best streak
After adding +1 to current streak, I would then check if current streak is > best streak. If yes, set current streak as best streak.

Historical best streak:
This one has me scratching my head. Ideally I could add the streak feature that’s backward compatible. This means scanning current user’s historical completed actions, and calculate all the streaks following a similar logic as the streak logic, only have the workflow calculate from the oldest entry all the way to the most recent one.

Would appreciate some help with:

  • Setting up the recurring workflow if this is what’s best
  • Setting up the logic in such a way that prevents double counting
  • Setting up a historical best streak “Scanner”

:fire:Thanks guys!

1 Like

Update 1:
The first thing I’ve found that really simplifies everything is that instead of doing a +1 to a streak number after users complete an action… I store a date into a list. Yep, it seems it’s simpler to do current streak as a list of dates instead.

Why? Here’s what I’m doing: When the user completes X action, I store current date changed to 00:00:00. So I add, for example, 4/4/2020 00:00:00.

So to prevent duplicates, all I have to do is check if there’s an entry with current date at 00:00:00. If there is, I don’t add any dates again.

Then to let users know their streak, I just do a Current Streak:count

1 Like

Amazing! Thanks for helping with this.

I’ve come to a slightly different solution.

When the user does the streak-building action,

  1. [MAKE THE CHANGE] the app changes their “Score”
  2. [ADD TO STREAK] Make changes to Current User -> Streak = Current User’s Streak + 1 ONLY WHEN Search for Thing’s Scores:last item’s Creation Date +(days): 1: formatted as 6/07/20 is Current date/time:formatted as 6/07/20
  3. [RESET STREAK] Make changes to Current User -> Streak = 1 ONLY WHEN Search for Thing’s Scores:last item’s Creation Date +(days): 1: rounded down to date < Current date/time
  4. [CREATE STREAK] Make changes to Current User -> Streak = 1 ONLY WHEN Current User’s Streak is empty
  5. [UPDATE LONGEST] Make changes to Current User -> Longest Streak = Current User’s Streak ONLY WHEN Current User’s Streak > Current User’s Longest Streak

Seems to be working so far.

What I haven’t figured out is showing the streak history in terms of which days you did the streak-building action and which you didn’t. I think your idea of building that list of dates will be helpful there!

1 Like

@Jici actually helped me out building the final solution, which is quite elegant.

—> After a user completes their first action, cancel, then reschedule an APi WF to reset the streak tomorrow at 23:59pm. This way, the user basically pushes back the “resetting” of their streak as long as they keep working out every day.

The streak is still the :count of a list of unique dates, which seems to be the best way to store a unique value that doesn’t require the laborious “Search for” function.

If you need additional help with workflows, highly recommend pinging @Jici for it.


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