Creating a streak system

Hello I’m creating a habit streak system for my app . I created two dates options sets , one" per day" that sets the current user starting date at " days:+1 and the other one “per week” at "days:+7 depending on the user starting date .

Created also a second date data for a deadline and a button to add +1 to the current habit point only avalaible if the current habit deadline is less than current datetime . If the deadline date is reached the streak is lost

Is there an easier way to make this streak system and how to schedule a reminder ( ex: 1 hour before ) to start the habit , please

You can calculate the streak dynamically, without any workflow scheduling. This is helpful because scheduling workflows/increasing a count in the backend falls apart when deleting activity logs/changing their date of etc.

It’s a little complex but the logic should work.

I will refer to two lists of dates. List of Dates A is a list of every date between the first date the user recorded a something, and the Current date/time.

List of Dates B is the user’s date entries. For an ‘activity’ streak, it’d be Search for Activities:each item’s date:each item rounded down to day:unique elements:sorted by date (ascending)

  1. Generate a list of dates (List of Dates A) that are all dates between the first date and last date you’re checking

  2. Find the most recent ‘missing’ (streak broken) date with ‘List of Dates A:minus list List of Dates B:last item

  3. Find the second most recent missing date with List of Dates A minus list List of Dates B:minus item # (List of Dates A minus List of Dates B:count - 1)

  4. Calculate the days between 3 and 2 (date 3 minus date 2:formatted as days) to calculate the current streak length.

You will find it is easiest to place these expressions in their own groups or use custom events rather than try to create one humongous expression. There are edge cases (e.g no streak at all) that can be accounted for with some simple logic.

Thank you for the response ; I have some questions

What is the use for the list dates B ? I am new to bubble ; I never knew you could record activities .

Second question , there is no data number for the streak ?cause I’d like to reward or punish the user ; maybe I can use the dates:count .

And lastly to schedule a reminder email for checking . You did not say anything

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