f24e24a20606465eb44dac7fb7c.../README.md
2025-07-31 09:22:27 +00:00

59 lines
2.0 KiB
Markdown

# Corrosion coupon report upload
Approximately every 90 days during the entire lifetime of an active pipeline the corrosion
coupon in a corrosion coupon retrieval point should be replaced. The removed coupon should
be weighed to assess the metal loss of the coupon during the days it was exposed in the
pipeline.
## Input
### Arguments
- `org_id`: as string which should be a valid `uuid` for the organization
- `project_id`: the id of the data project where the pipeline data is found
- `pipeline_id`: an `array` of `strings` which should be valid UUIDs for pipelines
- `coupon_retrieval_point_id`: an `array` of `strings` which should be valid UUIDs for coupon
retrieval points on the pipeline
- `installation_date`: a `string` formatted as an ISO date representing the date the corrosion
coupon was installed in the pipeline.
- `retrieval_date`: a `string` formatted as an ISO date representing the date the corrosion
coupon was retrieved from the pipeline.
- `metal_loss`: a `float` representing the measured metal loss of the coupon.
- `inspector`: a `string` representing the identifier of the inspector
- `remarks`: a `string` for any additional remarks about the inspection
## Creating the function on the platform
To create this function on the platform using the `cli` set up the port forwarding as shown in README.
Then run the following command to create the function.
```bash
cargo run functions create \
-f functions/corrosion_coupon_report \
-d "Creates new corrosion coupon reports" \
-i org_id=string \
-i project_id=string \
-i pipeline_id=array \
-i coupon_retrieval_point_id=array \
-i installation_date=string \
-i retrieval_date=string \
-i metal_loss=float \
-i inspector=string \
-i remarks=string
```
## Testing the function locally
You can run and test the function locally by running
```bash
cargo run
```
Then you can check it work with `curl` as follows
```bash
jq '. | tojson' functions/corrosion_coupon_report/example_input.json | curl -d '@-' localhost:8080
```