How to set the day of the week's name using set filter instead of a loop?

Hey all!

Im building an api which will group by the user's data to be shown on a daily bar chart. The chart will always start on the first day of the week and will represent only 7 days

I've build most of the process but at the very end I'm getting confused with the get/set filters. I know how to build it using the For Loop but I want to make it simpler using the get/set functions as I recently discovered them

At the moment this is what I do:

  1. Getting the user's timezone

  2. Creating a variable for the current week of the year

  3. Createing a variable for the current day of the week

  4. Creating a variable for the first day of the week's date (to be used later to filter all user data that only begins after this date)

  5. Then I'm doing something similar to create a date for the end of the week

  6. Then I query all user records that are between the start and the end of the week and group them by their date (extracting the day of week) and the habit_count

Now at this point I'm getting the data correctly with day of week being represented as a number (0 for sunday etc)

And at this point I wish to format the day of week's number to be the actual text such as "Sunday"/"Monday" etc

I can use a loop for that with 7 conditions and store it in an array variable, but after watching some videos abut get and set filters I wish to learn how to simplify such proccesess..

Would appreciate any help with this

Thanks a lot!

3 replies