# Reprocess UoWs
Script allows reprocessing UoWs in given date range 
using standard slz reprocessing. For each UoW it triggers Job manager lambda in reprocessing mode

## Usage(run script)

     reprocess --help
        usage: reprocess [-h] --env {dev,qa,stage,prod} --start-date START_DATE
                         --end-date END_DATE --report-name
                         {memberslogin,activityfeed,membersextended}
                         --uow-limit UOW_LIMIT [--completeness-rate COMPLETENESS_RATE]
                         [--debug] [--json]
        
        optional arguments:
          -h, --help            show this help message and exit
          --env {dev,qa,stage,prod}
          --start-date START_DATE
                                All units from this day(including) are to be
                                reprocessed: in format YYYYMMDD
          --end-date END_DATE   All units till this day(including) are to be
                                reprocessed: in format YYYYMMDD
          --report-name {memberslogin,activityfeed,membersextended}
          --uow-limit UOW_LIMIT
                                How many backfill units could be processed
                                simultaneously
          --completeness-rate COMPLETENESS_RATE
                                From 0-1. How many CS from all should be processed to
                                count this unit as completed for unit-limit
          --debug               additional log level
          --json                json output

## How to schedule reprocessing on stage/prod
OPTIONAL steps are for such cases when changes were made in 'reprocess' script.

1. [OPTIONAL] Build and upload the docker image containing this script:
   ```
   make docker/image/build && make docker/image/upload
   ```
2. connect to EC2 instance, created for backfill purposes
    ```text
   stage - ssh ubuntu@10.32.14.76
   prod - ssh ubuntu@10.33.14.185
    ```
3. go to folder with reprocess script
    ```text
    cd delphi-util/scripts/ae_reprocess
   ```
4. [OPTIONAL] Pull the latest image and latest changes 
   from repo(considering that you're on develop branch)
   ```text
    make docker/image/pull
   git pull origin develop
   ```
5. To add/clean crontab rule to launch the script:
 ```text
    make crontab/add
    make crontab/clean
   ```
5. If you need to change any parameter(ex. uow-limit or completeness-rate), 
   edit **reprocess_units.sh**
   ```text
    nano reprocess_units.sh
   ```
6. to check logs produced during execution.
   ```text
    tail -f ~/delphi-util/scripts/ae_reprocess/ae_reprocess.log
   ```