Skip to content

Commit

Permalink
Merge pull request #469 from IATI/develop
Browse files Browse the repository at this point in the history
Output new advisory field on reports
  • Loading branch information
simon-20 authored Jun 28, 2024
2 parents 451875c + 15f48b9 commit d72e8b3
Show file tree
Hide file tree
Showing 12 changed files with 396 additions and 339 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/develop-func-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
build:
uses: IATI/.github/.github/workflows/build_node_save.yaml@main
with:
npm_version: ^10
save_artifact: false

automerge:
Expand All @@ -25,6 +26,6 @@ jobs:
pull-requests: write
contents: write
steps:
- uses: fastify/github-action-merge-dependabot@v3.9
- uses: fastify/github-action-merge-dependabot@v3.10
with:
github-token: ${{secrets.GITHUB_TOKEN}}
9 changes: 5 additions & 4 deletions .github/workflows/develop-func-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
if: ${{ needs.should_run.outputs.should_run == 'true' }}
uses: IATI/.github/.github/workflows/build_node_save.yaml@main
with:
npm_version: ^10
save_artifact: true
artifact_name: build-artifact-dev

Expand All @@ -51,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build-artifact-dev

Expand All @@ -61,7 +62,7 @@ jobs:
rm build-artifact-dev.zip
- name: 'Login via Azure CLI'
uses: azure/login@v1.4.7
uses: azure/login@v2.1.1
with:
creds: ${{ env.AZURE_CREDENTIALS }} # Service Principal credentials saved in GitHub Secrets

Expand Down Expand Up @@ -139,7 +140,7 @@ jobs:
]
- name: 'Run Azure Functions Action'
uses: Azure/[email protected].1
uses: Azure/[email protected].2
with:
app-name: func-${{ env.NAME }}-${{ env.STAGE }}

Expand All @@ -151,7 +152,7 @@ jobs:
run: sleep 180

- name: 'Checkout GitHub Action'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Install newman'
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/prod-func-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
build_save:
uses: IATI/.github/.github/workflows/build_node_save.yaml@main
with:
npm_version: ^10
save_artifact: true
artifact_name: build-artifact-prod

Expand All @@ -37,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build-artifact-prod

Expand All @@ -47,7 +48,7 @@ jobs:
rm build-artifact-prod.zip
- name: 'Login via Azure CLI'
uses: azure/login@v1.4.7
uses: azure/login@v2.1.1
with:
creds: ${{ env.AZURE_CREDENTIALS }} # Service Principal credentials saved in GitHub Secrets

Expand Down Expand Up @@ -125,7 +126,7 @@ jobs:
]
- name: 'Run Azure Functions Action'
uses: Azure/[email protected].1
uses: Azure/[email protected].2
with:
app-name: func-${{ env.NAME }}-${{ env.STAGE }}

Expand All @@ -137,7 +138,7 @@ jobs:
run: sleep 180

- name: 'Checkout GitHub Action'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Install newman'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/iron
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Summary

| Product | Validator Services API |
| ---------------- | -------------------------------- |
| Description | Node.JS app that provides various API end points used by the IATI Validator API; also handles the validation for ad hoc data checks in user sessions on the Validator website. |
| Website | [https://validator.iatistandard.org](https://validator.iatistandard.org) |
| Related | [IATI/validator-web](https://github.com/IATI/validator-web), [IATI/js-validator-api](https://github.com/IATI/js-validator-api) |
| Documentation | [https://developer.iatistandard.org/](https://developer.iatistandard.org/) |
| Technical Issues | https://github.com/IATI/validator-services/issues |
| Support | https://iatistandard.org/en/guidance/get-support/ |

# validator-services

## Endpoints
Expand All @@ -23,7 +34,7 @@ See OpenAPI specification `postman/schemas/index.yaml`. To view locally in Swagg
- nvm - [nvm](https://github.com/nvm-sh/nvm) - Node version manager
- Node LTS
- once you've installed nvm run `nvm use` which will look at `.nvmrc` for the node version, if it's not installed then it will prompt you to install it with `nvm install <version>`
- [Azure Functions Core Tools v3](https://github.com/Azure/azure-functions-core-tools)
- [Azure Functions Core Tools v4](https://github.com/Azure/azure-functions-core-tools)
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) version 2.4 or later.

## Getting Started
Expand Down
6 changes: 4 additions & 2 deletions database/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ const getSummaryPrecalcStats = async (date, publisher) => {
T1.publisher_name,
SUM( (T1.report -> 'summary' ->> 'critical') :: INTEGER) as critical,
SUM( (T1.report -> 'summary' ->> 'error') :: INTEGER) as error,
SUM( (T1.report -> 'summary' ->> 'warning') :: INTEGER) as warning
SUM( (T1.report -> 'summary' ->> 'warning') :: INTEGER) as warning,
SUM(COALESCE((T1.report -> 'summary' ->> 'advisory') :: INTEGER, 0)) as advisory
FROM validation AS T1
WHERE T1.created <= $1
AND T1.publisher_name = $2
Expand All @@ -443,7 +444,8 @@ const getSummaryPrecalcStats = async (date, publisher) => {
T1.publisher_name,
SUM( (T1.report -> 'summary' ->> 'critical') :: INTEGER) as critical,
SUM( (T1.report -> 'summary' ->> 'error') :: INTEGER) as error,
SUM( (T1.report -> 'summary' ->> 'warning') :: INTEGER) as warning
SUM( (T1.report -> 'summary' ->> 'warning') :: INTEGER) as warning,
SUM(COALESCE((T1.report -> 'summary' ->> 'advisory') :: INTEGER, 0)) as advisory
FROM validation AS T1
WHERE T1.created <= $1
AND T1.publisher_name IS NOT NULL
Expand Down
47 changes: 32 additions & 15 deletions integration-tests/validator-services-tests.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"_postman_id": "670a6541-0509-4d79-8b62-550460c4a700",
"name": "validator-services-tests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "28259772"
"_exporter_id": "29844336",
"_collection_link": "https://iatisecretariat.postman.co/workspace/IATI~c354ba4e-15bf-41ee-9d69-a5a5360da160/collection/13097277-670a6541-0509-4d79-8b62-550460c4a700?action=share&source=collection_link&creator=29844336"
},
"item": [
{
Expand Down Expand Up @@ -130,7 +131,8 @@
" pm.collectionVariables.set(\"publisher_name\", jsonData[1].name);",
"})"
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
Expand Down Expand Up @@ -1793,10 +1795,14 @@
"});",
"pm.test(\"Expect objects in the Array to have certain keys\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData['worldbank']).to.have.keys(['critical', 'error', 'warning']);",
" Object.values(jsonData).forEach((item) => {",
" var keys = Object.keys(item).filter(k => ['critical', 'error', 'warning'].includes(k));",
" pm.expect(keys).to.deep.equal(['critical', 'error', 'warning']);",
" });",
"});"
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
Expand Down Expand Up @@ -1824,17 +1830,27 @@
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () { pm.response.to.have.status(200); });",
"pm.test(\"Expect body to be an Object\", function () {",
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"})",
"",
"pm.test('Expect body to be an Object', function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.be.an('object')",
"});",
" pm.expect(jsonData).to.be.an('object');",
"})",
"",
"pm.test(\"Expect objects in the Array to have certain keys\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData['worldbank']).to.have.keys(['critical', 'error', 'warning']);",
"});"
" Object.values(jsonData).forEach((item) => {",
" var keys = Object.keys(item).filter(k => ['critical', 'error', 'warning'].includes(k));",
" pm.expect(keys).to.deep.equal(['critical', 'error', 'warning']);",
" });",
"});",
"",
""
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
Expand Down Expand Up @@ -1909,26 +1925,27 @@
"});",
"pm.test(\"Expect object to have certain keys\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.keys(['worldbank']);",
" pm.expect(jsonData).to.have.keys(pm.collectionVariables.get(\"publisher_name\"));",
"});"
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseURL}}/pub/stats/publisher/worldbank",
"raw": "{{baseURL}}/pub/stats/publisher/{{publisher_name}}",
"host": [
"{{baseURL}}"
],
"path": [
"pub",
"stats",
"publisher",
"worldbank"
"{{publisher_name}}"
]
}
},
Expand Down
Loading

0 comments on commit d72e8b3

Please sign in to comment.