Create a monthly scoreboard with empty months filled :)

Hello everyone,

I have a feature I’m struggling to build and ill be grateful if someone could help with it.
I want to build a monthly scoreboard that will collect points in the local data source based on the month and year. every month there should be a new row created and the points are calculated there.

so far so good.
my only problem is when there are months without points.
what should I do to create a solution that will create rows with zero points based on the distance between the last filled month to the new one?

is anyone knows how to build such an algorithm?

Thanks in advance!

1 Like

Nice idea, the answer would be helpful to me too.

1 Like

u can use firebase.but i am not firebase expert . just suggested

Can you explain more about what the row values would look like and if the user is entering them and why (what scores are they keeping track of)? Why does a zero value cause an issue?

The user gets points from completing tasks.
Each month the points are summed and in the next month, it should add a new row with the new monthly points.
When the user does not play for one month I want it to add all the missing months automatically when he creates the new month points.

Hope I explained it well.

One strategy would be:

  1. Each time app is opened (start screen - start event)
  2. Find the most recent year and month in the local db.
  3. For each month between the last month in the local db and the current month
  4. Add an entry for the year and month with all scores = 0
  5. Then proceed to calculate the total Point as previously, with any totals found overwriting the zero score entries created in the previous step.

How do you 3?
if the year has changed how do i calculate the right distance?

What do you mean by “distance”? Do you mean physical distance on the screen as in x/y coordinates? Or time between months…? Perhaps a sketch of your scoreboard screen layout will help make this clearer.

no, no physical. the time between months :slight_smile:

There are a number of ways to approach this problem. Because of my many years of SQL database work, I tend to prefer something like this:

This approach eliminate calculating differences between dates, december to january comparisons, etc. It will loop a few extra times, but those loops do not do much so they will be extremely fast.

Happy Thunking!

4 Likes

Hey, I tried it, but unfortunately I wasn’t able to create the functionality I desire with the new rows. can you please show in more detail how I do it with the creation of new row when there’s a new month / how can I update the current month score?

I’m not sure how the rest of your app works, so it is hard to show an example.

Where are your scores coming from? Firebase? Airtable? Google Sheets? Variables inside the app?

variables inside the app…

Are the scores stored as lists? JSON Object? Can you share some images of how the variables are set?

And how are the variables in the app populated? do users type the values in?

They are stored in the local data source.
when the user finishes a task he gets points.
right now the points are calculated in a one table with one row on which all the calculations are.
I want to add a new table with the same columns but just with option to split the row based on the current month.
and off course leave empty rows when the user did nothing in that month.

Thank you, that helps me understand what you are trying to do.

In my example above, you will need to create 3 functions:
Are There Tests

  • Loop through the local data source
  • If the year in the datasource = YEAR variable AND month in the data source = MONTH variable, then return true, else, return false

Insert Test Results

  • Loop through the local data source
  • If the year in the datasource = YEAR variable AND month in the data source = MONTH variable
  • Copy the contents of the raw scores into the “New” datasource

Insert Zeros

  • Insert a row in the “new” data source using the Year and Month variable values and zeros for all of the scores

I don’t use local data sources, so you will need to come up with the blocks get and set cell values.