goinvo/staffplan_redux

Changes to `Mutations::UpsertWorkWeek`

Closed this issue ยท 6 comments

Currently the estimatedHours and actualHours fields are optional for each work week passed by the UI. The field is required by the database, however, and there isn't any cleanup done of work weeks that have their values set to empty/0 via the "fill" function.

Let's change the behavior of this mutation to handle deletion of existing work weeks for the current/future dates if it's passed null or 0 as a value for estimatedHours for the work week. After this, blanking out an input for estimatedHours for a work week and clicking the fill arrow should delete any existing records in the database passed over GraphQL.

/cc @HankC138 @zhukovdigital for ๐Ÿ‘€

@HankC138 @fermion Also i think we need to figure out it not only for future weeks. For previous weeks which has no actual hours. And for upsertWorkWeek mutation. No actual and estimated hours = delete work week/ weeks from db. What do you think?

@zhukovdigital database records for work weeks are created on demand  โ€” a brand new assignment has no records in the work_weeks table. They're added as the mutations are called to manage them. In theory if we're cleaning up work weeks that get null or 0 hours passed for the estimatedHours then I think we're in good shape since there won't be any records for previous weeks where both could be 0?

@fermion Do we need a new mutation for it? Or you just can delete those weeks in DB and send in respond for upsertWorkWeeks assignment without these deleted weeks?

@zhukovdigital I'll update the existing mutation to prune future work weeks that are sent with a null or 0 for estimatedHours ๐Ÿ‘๐Ÿป The response will return back only persisted work weeks, I think that's what you're expecting?

@fermion yup, cool!

Fixed in #350