# Reservers Schedule

## Overview

This lambda makes `GET` requests in batches to ows-ledger service to
get ledger_reserve_taken entries. Then it gets contract_reserve items
from ows-royalties and based on those two sets of entries
it creates ledger_reserve_release_schedule entries via `ScheduleEntriesProcessor`
module. For the created release_schedule entries it makes `POST` requests in chunks
to save them into the table.

## Getting Started

### Requirements

- Python 3.11
- Docker

### OWS Dependencies

- [ows-ledger](https://github.com/theorchard/ows-ledger)
- [ows-royalties](https://github.com/theorchard/ows-royalties)

### Installation

Create a `.env` file based on the `.env.shadow` and fill in the values:

```bash
$ cp .env.shadow .env
```

Create a virtual env and install the requirements:

```bash
$ make dev_env
```

### Running

You can run the function locally with: `make run`

Or you can run the function inside Docker with: `make docker_local_up` and trigger an event with `make local_event`

### Testing

You can run the linter and the unit tests locally with: `make lint` and `make test`

Or you can run the linter and the unit tests inside Docker with: `make docker_test`

The integration tests can only be run inside Docker with: `make docker_test_integration`

**Note:**
You might need to login to Docker with the shared AWS account in order to run the integration tests:

```bash
$ awsume <shared_profile>
$ make docker_login
```

### Adding new packages

- For dev packages, add them normally to `requirements-dev.txt`
- For regular packages, add the new top level package name
  and optionally version constraints to `requirements-to-freeze.txt`
- Run `make pip_lock_versions`

### Upgrading packages

Regularly running `make pip_lock_versions` will update and freeze all non-dev dependencies in `requirements.txt`
