Code-4-Community / breaktime-backend

2 stars 0 forks source link

Timesheet API: Add in filtering by date range for GET timesheets endpoint #25

Open izzyconner opened 1 year ago

izzyconner commented 1 year ago

Linked to story item 14

As a developer, I want to have an optional way to get only a certain amount of timesheets based on a date range.

To support this, we should add optional startDate and endDate queries to the getTimesheets endpoint on the backend. These should expect to take in an numerical epoch value. If the startDate given is not the start of the week, the backend should round the epcoh to 00:00:00 of that week's Sunday.

The backend should filter DynamoDB queries by:

  1. any timesheet item whose StartDate field is >= the startDate query AND
  2. any timesheet item whose StartDate field is < the endDate query

Default values for the queries should be as follows:

  1. If no startDate query is provided, the default start date should be 3 weeks prior to the current week's Sunday. That is, if today is Friday, May 12th, the default weeks returned should be for Sunday May 7th, Sunday April 30th, and Sunday April 23rd.
  2. If no endDate query is provided, the default end date should be the startDate + 1

If no timesheet is found for that week(s), create new TimesheetSchema object for all companies the user belongs to, write them to the BreaktimeTimesheet DynamoDB table, and return the new TimesheetSchemas. By default, the TimesheetSchema attributes that should be populated for a new timesheet are:

Conditions of satisfaction (make sure to test these manually or with automated tests):