Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks
izzyconner opened this issue Apr 20, 2023 · 0 comments
Open
5 tasks
Assignees

Comments

@izzyconner
Copy link
Collaborator

izzyconner commented Apr 20, 2023

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:

  • UserId : the current user's sub
  • TimesheetId : a new generated uuid
  • CompanyId: the companyId it's being generated for
  • StartDate: the 00:00:00 Sunday epoch for the week of the startDate query, or the appropriate week's epoch if multiple weeks are requested
  • Status: an status object with each flag undefined
  • all arrays (WeekNotes, HoursData, and ScheduleTableData) should default to empty arrays

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

  • Can request timesheets without any date range queries, and I should receive this week's timesheet + 2 weeks prior timesheets
  • Can request timesheet with only a startDate query, and I should receive only that week's timesheet
  • Can request timesheet with a startDate and endDate query, and I should receive all timesheets for that user
  • Can request timesheets with a non-Sunday startDate query, and I should still receive the correct week's timesheet
  • Can request timesheets with dates (queried or default) that include 1 or more weeks that do not have a timesheet in DynamoDB, and all appropriate timesheets should be created in DynamoDB and returned with all necessary fields filled out. All existing timesheets for the requested date range should also be returned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants