Open
Description
Create a script inside scripts
directory which we can run by npm run util:recalculate-work-periods
which would recalculate Work Period fields:
daysPiad
paymentTotal
paymentStatus
using the same logic which we use during WP or WPP update.
This script should allow us to specify particular Wokr Period id to recalculate data for like npm run util:recalculate-work-periods --- <WorkPeriodId>
The reason for having such script is the next:
- if our logic fail for some reason
- we may find out that current logic has some issue, and we want to change the logic and after recalculate values for all Work Periods
Requirements:
- It should only update WP if recalculated values changes
- the logic itself should be reused in this script and inside event handler and endpoint, so we should be able to change this logic in one place and it would be reused in all the places where it's need for consistency.
- I guess it would be much easier if this script only updates DB. Otherwise if send many events to update data in ES it may take too much time. So we I think we could use this script like this:
- stop TaaS API and ES Processor
- run this script to recalcuate values for WP in DB
- reindex all RB with WPs and WPPs