## Auto Add Contributions
Lambda for adding newly created contributions to the schedule marked "auto_add" for the related contributor (if it exists.)

## Requirements
- Python 3.11

## GRAPHQL Dependencies
Unlike the other lambdas in lambda-abacus, this needs to use graphql rather than the ows microservices, this is because contribution info and updates are only available through neo4j via graphql.
This will hit the graphql router, but it should specifically hit two subgraphs within that.

- [graphql-abacus](https://github.com/theorchard/graphql-abacus)
- [graphql-neighbouring-rights](https://github.com/theorchard/graphql-neighbouring-rights)

## Running 


### Set up the environment

```
# After generating aws creds
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 437795906767.dkr.ecr.us-east-1.amazonaws.com
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 086679231553.dkr.ecr.us-east-1.amazonaws.com
```

```
cp .env.shadow .env
```

```
source env
```

### Start local lambda

```
$ make docker_local_up
```

Note: This brings up the local code, if you want to pull and run the most recently deployed image run `make start_ows`, it may take a while either way 

### Execute Function

Use the HTTP client of your choice. The body of the request is the `event` passed into the function.

```
$ curl --request POST \
  --url http://localhost:9000/2015-03-31/functions/function/invocations \
  --header 'Content-Type: application/json' \
  --data $(cat tests/sample_event.json)
```

### Running the linter and the unit tests

```
make docker_test
```

### Running the integration tests

```
make test_integration
```

env vars required for integration tests are defined in tests\integration\integr_test_envvars.env 

Note: this is set up to run against the most recently deployed image, so if you want it to run against any local changes you'll need to set it up differently.
