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:
any timesheet item whose StartDate field is >= the startDate query AND
any timesheet item whose StartDate field is < the endDate query
Default values for the queries should be as follows:
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.
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
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
andendDate
queries to thegetTimesheets
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:
StartDate
field is >= thestartDate
query ANDStartDate
field is < theendDate
queryDefault values for the queries should be as follows:
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.endDate
query is provided, the default end date should be thestartDate
+ 1If 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 newTimesheetSchema
s. By default, theTimesheetSchema
attributes that should be populated for a new timesheet are:UserId
: the current user's subTimesheetId
: a new generated uuidCompanyId
: the companyId it's being generated forStartDate
: the 00:00:00 Sunday epoch for the week of thestartDate
query, or the appropriate week's epoch if multiple weeks are requestedStatus
: an status object with each flag undefinedWeekNotes
,HoursData
, andScheduleTableData
) should default to empty arraysConditions of satisfaction (make sure to test these manually or with automated tests):
startDate
query, and I should receive only that week's timesheetstartDate
andendDate
query, and I should receive all timesheets for that userstartDate
query, and I should still receive the correct week's timesheet