From 53b4b80bea24f1a65434769dde9990f0f6f1e2bd Mon Sep 17 00:00:00 2001 From: lanseg Date: Fri, 19 Jul 2024 18:07:10 +0200 Subject: [PATCH] Add docs and testing guide to the README (#7) * Add docs and testing guide to the README * Apply suggestions from code review Co-authored-by: Marion Baumgartner --------- Co-authored-by: Andrey Rusakov Co-authored-by: Marion Baumgartner --- README.md | 23 ++++++++++++++++++++++- docker-compose.yaml | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b200c87..9058823b 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,27 @@ This repository contains a working example of the * [Geoshop Extract connector](https://github.com/sitn/sitn_geoshop_connector) * [Geoshop backend](https://github.com/camptocamp/geoshop-back/) -### How to run +## How to run It should be enough to run ```docker compose up```, docker will build all the images and start the containers. +### How to test +Extract fetches orders by sending a ```GET http://geoshop_host:8000/extract/order/``` request periodically. Geoshop returns all requests that are eligible for extracting, marks them as ```in_extract``` and will not return it again. + +[ExtractOrderView](https://github.com/camptocamp/geoshop-back/blob/master/api/views.py#L349) handles the request, it will return OrderItems which are: + +* Order status is either READY or PARTIALLY_DELIVERED +* Order provider is the user that makes request (extract in our case) +* OrderItem status is PENDING + +### Utility scripts + +To create an order to be picked by Extract, send this script to the ```Geoshop's``` postgres database. + +```sql + +--- Create an Order (A rectangle) +INSERT INTO "order" (title, description, processing_fee_currency, processing_fee, total_without_vat_currency, total_without_vat, part_vat_currency, part_vat, total_with_vat_currency, total_with_vat, geom, invoice_reference, date_ordered, date_downloaded, date_processed, client_id, invoice_contact_id, order_type_id, extract_result, download_guid, email_deliver, order_status) VALUES ('New demo order', '', 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, '0103000020080800000100000005000000E0609D479AAF1141DCE4284375FD4BC1009C5A7EEBDDCEC066574A1D448B52C111DEA19A8E293A41E8A550A937FF53C1EC647D947B943B41523BEBFDA75E4EC1E0609D479AAF1141DCE4284375FD4BC1', '', NOW(), NULL, NULL, 3, NULL, 1, '', '4c1391f3-53b5-4130-b0d7-bbbdfc26fb81', '', 'READY'); + +-- Create a relevant OrderItem order_id=CURRVAL('order_id_seq') +INSERT INTO order_item (last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 1, CURRVAL('order_id_seq'), 1, '', 2056, 'PENDING', NULL, NULL, NULL); +``` diff --git a/docker-compose.yaml b/docker-compose.yaml index 88f9ff4f..a3b126d9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -67,7 +67,7 @@ services: ports: - "5432:5432" healthcheck: - test: ["CMD-SHELL", "pg_isready -U extract"] + test: ["CMD-SHELL", "pg_isready -U extractuser" -d postgres] interval: 5s timeout: 5s retries: 5