Short system date and smart set column value

I am making a meditation app. My app is considered to calculate overall time (minutes) spent by a user on a meditation practice (there are several types of meditation practice). After each practice of a certain type, the user enters how many minutes this practice lasted.

Now my algorithm works in such a way that every time the user taps the button in app, another row is added (containing user id, date and time from the system and the number of minutes spent on practice of certain type, where number of minutes is a value that is chosen by the user from a pre-formed list of fixed values).

To calculate stats I need a user id and short date with out time.

I wish to decrease rows. I want to use algorithm where every new row is added only if the user ID and date does not exist in database before.

Another case (id and date is in the base), it is the data ‘minutes spent on practice X’ that should be overwritten. Other user data (ID, practice type) should stay untouched.

Tell me which algorithm is better to use. So I try to make ÂŤone button/tapÂť experience for friends. I would really appreciate your help.

My search attempts have been unsuccessful so far(

I’m making an assumption that you’re trying to optimize a meditation app’s data storage to reduce redundant entries when users log practice times, and each user should have one entry per practice type, updating minutes if the entry already exists.

You have 2 ways to go here.

If you don’t need admins or other users to view a person’s logs, you can use the new stopwatch component, point it to a user-specific column, and it will work just like that.

If not, you must use a combination of stopwatch and a Logs table. The logs should look like this:

User ID Practice ID Time spent (seconds)
U001 P001 120
U001 P002 3600

In the Practices table, create a query to the Logs table, filtering by:

  • User ID is signed-in user’s ID
  • Practice ID is current row > practice ID

Then, add a single value column > whole row on top of the query to get the one row that matches.

Add a “Submit log” button.

  • If the single value column above is empty, add a row to the Logs table.
  • If not, use an increment action, increment the elapsed time through the single value column above, to the time spent column.

Only caveat is the user has to reset the stopwatch every time they want to start a new session.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.