Filter an API call based on object created time

Options
I have an API that calls a large amount of user inputted data that I want to paginate by time. For this I need to edit my current API that calls all data by user and make a version that calls only entries made in on the current day, and a version that calls only entries made in the current week.

I have got as far as cloning the API I already have and looking at adding a conditional but I'm running into issues knowing where to go next:

[Screenshot 2022-01-14 at 18.37.38.png]

Any help much appreciated!

Thanks

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    To get entries of the current day, I would consider using the timestamp_epoch_day filter like this:

    [CleanShot 2022-01-14 at 14.22.12.png]
    timestamp_epoch_day is the day number since Jan 1., 1970


    To get entries of the same week, I would consider a couple of where statements grouped together such as:

    [CleanShot 2022-01-14 at 14.26.29.png]
    To get the same week, you would want to use timestamp_week and timestamp_year so that you are making sure the week and year is the same. Since there isn't an epoch filter for week.
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Otherwise if you just used week and you have entries over multiple years, it would be possible that you could grab entries that are the same week but from different years. 

    So also accounting for the year filters by that too.