diff --git a/Dockerfile b/Dockerfile index d31a5ae7e..c114c02b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # FunderMaps Ecosystem # Build application solution -FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build +FROM mcr.microsoft.com/dotnet/sdk AS build WORKDIR /source # The subtool must be defined. The build container will only build the @@ -29,7 +29,7 @@ RUN dotnet publish -c release -o /app \ && cp /source/contrib/etc/_appsettings.Staging.json /app/appsettings.Staging.json # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal +FROM mcr.microsoft.com/dotnet/aspnet ENV DOTNET_PRINT_TELEMETRY_MESSAGE=false WORKDIR /app COPY --from=build /app . diff --git a/contrib/interface/FunderMaps.WebApi.postman_collection.json b/contrib/interface/FunderMaps.WebApi.postman_collection.json deleted file mode 100644 index 91e9da14b..000000000 --- a/contrib/interface/FunderMaps.WebApi.postman_collection.json +++ /dev/null @@ -1,1503 +0,0 @@ -{ - "info": { - "_postman_id": "8dc8ba47-b860-4bc2-8b69-63901d248853", - "name": "FunderMaps.WebApi", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Inquiry", - "item": [ - { - "name": "Create Inquiry", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.environment.set(\"inquiry_id\", pm.response.json()[\"id\"])", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"DocumentName\": \"{{$randomFileName}}\",\r\n \"Inspection\": {{$randomBoolean}},\r\n \"JointMeasurement\": {{$randomBoolean}},\r\n \"FloorMeasurement\": {{$randomBoolean}},\r\n \"Note\": \"{{$randomLoremSentences}}\",\r\n \"DocumentDate\": \"{{$isoTimestamp}}\",\r\n \"DocumentFile\": \"{{$randomFileName}}\",\r\n \"Type\": 2,\r\n \"StandardF3o\": {{$randomBoolean}},\r\n \"Contractor\": \"11cdc51f-3ba6-4e3c-b975-dfed4f054c31\",\r\n \"Reviewer\": \"9d1b111a-c024-470c-b0b7-6810140924e8\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry" - ] - } - }, - "response": [] - }, - { - "name": "Upload Inquiry Document", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "input", - "type": "file", - "src": "file.pdf" - } - ] - }, - "url": { - "raw": "{{base_url}}/api/inquiry/upload-document", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "upload-document" - ] - } - }, - "response": [] - }, - { - "name": "Get Inquiry", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Get All Inquiries", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/inquiry", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry" - ] - } - }, - "response": [] - }, - { - "name": "Update Inquiry", - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"documentName\": \"{{$randomFileName}}\",\r\n \"inspection\": {{$randomBoolean}},\r\n \"jointMeasurement\": {{$randomBoolean}},\r\n \"floorMeasurement\": {{$randomBoolean}},\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"documentDate\": \"{{$isoTimestamp}}\",\r\n \"documentFile\": \"{{$randomFileName}}\",\r\n \"type\": 2,\r\n \"standardF3o\": {{$randomBoolean}},\r\n \"auditStatus\": 0,\r\n \"reviewer\": \"9d1b111a-c024-470c-b0b7-6810140924e8\",\r\n \"contractor\": \"11cdc51f-3ba6-4e3c-b975-dfed4f054c31\",\r\n \"accessPolicy\": 0,\r\n \"createDate\": \"2020-10-07T14:50:57.970056+02:00\",\r\n \"updateDate\": null\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Review Inquiry", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"Message\": \"{{$randomLoremSentences}}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/status_review", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "status_review" - ] - } - }, - "response": [] - }, - { - "name": "Reject Inquiry", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"Message\": \"{{$randomLoremSentences}}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/status_rejected", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "status_rejected" - ] - } - }, - "response": [] - }, - { - "name": "Approve Inquiry", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"Message\": \"{{$randomLoremSentences}}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/status_approved", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "status_approved" - ] - } - }, - "response": [] - }, - { - "name": "Delete Inquiry", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Inquiry Sample", - "item": [ - { - "name": "Create Inquiry Sample", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.environment.set(\"inquiry_sample_id\", pm.response.json()[\"id\"])", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"Note\": \"{{$randomLoremSentences}}\",\r\n \"Address\": \"{{address_id}}\",\r\n \"BuiltYear\": \"{{$isoTimestamp}}\",\r\n \"Cpt\": \"{{$randomFileName}}\",\r\n \"MonitoringWell\": \"{{$randomFileName}}\",\r\n \"EnforcementTerm\": 9,\r\n \"RecoveryAdvised\": {{$randomBoolean}},\r\n \"WoodQualityNecessity\": {{$randomBoolean}},\r\n \"CrackIndoorRestored\": {{$randomBoolean}},\r\n \"CrackFacadeFrontRestored\": {{$randomBoolean}},\r\n \"CrackFacadeLeftRestored\": {{$randomBoolean}},\r\n \"CrackFacadeRightRestored\": {{$randomBoolean}},\r\n \"DeformedFacade\": {{$randomBoolean}},\r\n \"ThresholdUpdownSkewed\": {{$randomBoolean}}\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/sample", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "sample" - ] - } - }, - "response": [] - }, - { - "name": "Get Inquiry Samples", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/sample/{{inquiry_sample_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "sample", - "{{inquiry_sample_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Get All Samples", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/sample", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "sample" - ] - } - }, - "response": [] - }, - { - "name": "Update Inquiry Sample", - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"address\": \"{{address_id}}\",\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"builtYear\": \"{{$isoTimestamp}}\",\r\n \"substructure\": 0,\r\n \"cpt\": null,\r\n \"monitoringWell\": null,\r\n \"groundwaterLevelTemp\": 0,\r\n \"groundLevel\": 0,\r\n \"groundwaterLevelNet\": 0,\r\n \"type\": 0,\r\n \"enforcementTerm\": 0,\r\n \"recoveryAdvised\": false,\r\n \"damageCause\": 0,\r\n \"damageCharacteristics\": 0,\r\n \"constructionPile\": 0,\r\n \"woodType\": 0,\r\n \"woodEncroachement\": 0,\r\n \"constructionLevel\": 0,\r\n \"woodLevel\": 0,\r\n \"pileDiameterTop\": 0,\r\n \"pileDiameterBottom\": 0,\r\n \"pileHeadLevel\": 0,\r\n \"pileTipLevel\": 0,\r\n \"foundationDepth\": 0,\r\n \"masonLevel\": 0,\r\n \"concreteChargerLength\": 0,\r\n \"pileDistanceLength\": 0,\r\n \"woodPenetrationDepth\": 0,\r\n \"overallQuality\": 0,\r\n \"woodQuality\": 0,\r\n \"constructionQuality\": 0,\r\n \"woodCapacityHorizontalQuality\": 0,\r\n \"pileWoodCapacityVerticalQuality\": 0,\r\n \"carryingCapacityQuality\": 0,\r\n \"masonQuality\": 0,\r\n \"woodQualityNecessity\": false,\r\n \"crackIndoorRestored\": false,\r\n \"crackIndoorType\": 0,\r\n \"crackIndoorSize\": 0,\r\n \"crackFacadeFrontRestored\": false,\r\n \"crackFacadeFrontType\": 0,\r\n \"crackFacadeFrontSize\": 0,\r\n \"crackFacadeBackRestored\": false,\r\n \"crackFacadeBackType\": 0,\r\n \"crackFacadeBackSize\": 0,\r\n \"crackFacadeLeftRestored\": false,\r\n \"crackFacadeLeftType\": 0,\r\n \"crackFacadeLeftSize\": 0,\r\n \"crackFacadeRightRestored\": false,\r\n \"crackFacadeRightType\": 0,\r\n \"crackFacadeRightSize\": 0,\r\n \"deformedFacade\": false,\r\n \"thresholdUpdownSkewed\": false,\r\n \"thresholdFrontLevel\": 0,\r\n \"thresholdBackLevel\": 0,\r\n \"skewedParallel\": 0,\r\n \"skewedPerpendicular\": 0,\r\n \"skewedFacade\": 0,\r\n \"settlementSpeed\": 0,\r\n \"createDate\": \"2020-10-07T15:33:17.709187+02:00\",\r\n \"updateDate\": null,\r\n \"deleteDate\": null\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/sample/{{inquiry_sample_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "sample", - "{{inquiry_sample_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Delete Inquiry Sample", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/api/inquiry/{{inquiry_id}}/sample/{{inquiry_sample_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "inquiry", - "{{inquiry_id}}", - "sample", - "{{inquiry_sample_id}}" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ] - }, - { - "name": "Recovery", - "item": [ - { - "name": "Create Recovery", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "pm.globals.set('randomRecoveryType', _.random(0, 4));\r", - "\r", - "const zeroPad = (num, places) => String(num).padStart(places, '0')\r", - "pm.globals.set('randomDateTime', `${_.random(1970, 2020)}-${zeroPad(_.random(1,12), 2)}-${zeroPad(_.random(1,28), 2)}`);" - ], - "type": "text/javascript" - } - }, - { - "listen": "test", - "script": { - "exec": [ - "pm.environment.set(\"recovery_id\", pm.response.json()[\"id\"])\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"documentDate\": \"{{randomDateTime}}\",\r\n \"documentFile\": \"{{$randomCommonFileName}}\",\r\n \"type\": {{randomRecoveryType}},\r\n \"attribution\": 207\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/recovery", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery" - ] - } - }, - "response": [] - }, - { - "name": "Get Recovery", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Get Recovery Document", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}/download", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}", - "download" - ] - } - }, - "response": [] - }, - { - "name": "Get All Recovery", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery" - ] - } - }, - "response": [] - }, - { - "name": "Update Recovery", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "pm.globals.set('randomRecoveryType', _.random(0, 4));\r", - "\r", - "const zeroPad = (num, places) => String(num).padStart(places, '0')\r", - "pm.globals.set('randomDateTime', `${_.random(1970, 2020)}-${zeroPad(_.random(1,12), 2)}-${zeroPad(_.random(1,28), 2)}`);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"documentDate\": \"{{randomDateTime}}\",\r\n \"documentFile\": \"3516cbe8-c70a-47ef-8d85-30139b972c28.txt\",\r\n \"type\": {{randomRecoveryType}},\r\n \"attribution\": 1,\r\n \"accessPolicy\": 1,\r\n \"createDate\": \"{{randomDateTime}}\",\r\n \"updateDate\": null,\r\n \"deleteDate\": null\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Delete Recovery", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Upload Recovery Document", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "input", - "type": "file", - "src": "file.pdf" - } - ] - }, - "url": { - "raw": "{{base_url}}/api/recovery/upload-document", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "upload-document" - ] - } - }, - "response": [] - }, - { - "name": "Get Recovery Stats", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/4", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "4" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Recovery Sample", - "item": [ - { - "name": "Create Recovery Sample", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "pm.globals.set('randomRecoveryType', _.random(0, 4));\r", - "\r", - "const zeroPad = (num, places) => String(num).padStart(places, '0')\r", - "pm.globals.set('randomDateTime', `${_.random(1970, 2020)}-${zeroPad(_.random(1,12), 2)}-${zeroPad(_.random(1,28), 2)}`);" - ], - "type": "text/javascript" - } - }, - { - "listen": "test", - "script": { - "exec": [ - "pm.environment.set(\"recovery_sample_id\", pm.response.json()[\"id\"])\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"address\": \"gfm-00000163c7e04fa9a562688df1e077b9\",\r\n \"permit\": \"{{$randomBsBuzz}}\",\r\n \"permitDate\": \"{{randomDateTime}}\",\r\n \"recoveryDate\": \"{{randomDateTime}}\",\r\n \"facade\": []\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}/sample", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}", - "sample" - ] - } - }, - "response": [] - }, - { - "name": "Get Recovery Sample", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/2/sample/3", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "2", - "sample", - "3" - ] - } - }, - "response": [] - }, - { - "name": "Get Recovery Sample Stats", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/4", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "4" - ] - } - }, - "response": [] - }, - { - "name": "Update Recovery Sample", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "const zeroPad = (num, places) => String(num).padStart(places, '0')\r", - "const facades = [];\r", - "for (var i = 0; i < _.random(0,10); i++) {\r", - " facades.push(_.random(0,3));\r", - "}\r", - "\r", - "pm.globals.set('randomRecoveryType', _.random(0, 4));\r", - "pm.globals.set('randomDateTime', `${_.random(1970, 2020)}-${zeroPad(_.random(1,12), 2)}-${zeroPad(_.random(1,28), 2)}`);\r", - "pm.globals.set('randomRecoveryDate', `${_.random(1970, 2020)}-${zeroPad(_.random(1,12), 2)}-${zeroPad(_.random(1,28), 2)}`);\r", - "pm.globals.set('randomFacadeArray', facades);\r", - "pm.globals.set('randomPileType', _.random(0, 2));\r", - "pm.globals.set('ramdomRecoveryType', _.random(0, 5));\r", - "pm.globals.set('randomRecoveryStatus', _.random(0, 2));\r", - "\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"address\": \"gfm-91f5141a92fa485f9a2d39c1c12b5390\",\r\n \"status\": {{randomRecoveryStatus}},\r\n \"permit\": \"{{$randomBsBuzz}}\",\r\n \"permitDate\": \"{{randomDateTime}}\",\r\n \"recoveryDate\": \"{{randomRecoveryDate}}\",\r\n \"facade\": [{{randomFacadeArray}}],\r\n \"pileType\": {{randomPileType}},\r\n \"type\": {{randomRecoveryType}}\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}/sample/{{recovery_sample_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}", - "sample", - "{{recovery_sample_id}}" - ] - } - }, - "response": [] - }, - { - "name": "Delete Recovery Sample", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/api/recovery/{{recovery_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "recovery", - "{{recovery_id}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Incident", - "item": [ - { - "name": "Create Incident", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"Name\": \"{{$randomFullName}}\",\r\n \"ClientId\": 3,\r\n \"Email\": \"{{$randomEmail}}\",\r\n \"PhoneNumber\": \"06360557722\",\r\n \"FoundationType\": 5,\r\n \"Address\": \"gfm-00000163c7e04fa9a562688df1e077b9\",\r\n \"FoundationDamageCharacteristics\": [\r\n 1,\r\n 3\r\n ],\r\n \"EnvironmentDamageCharacteristics\": [\r\n 1\r\n ],\r\n \"Owner\": {{$randomBoolean}},\r\n \"FoundationRecovery\": {{$randomBoolean}},\r\n \"NeighborRecovery\": {{$randomBoolean}},\r\n \"FoundationDamageCause\": 6,\r\n \"DocumentFile\": [\r\n \"{{$randomFileName}}\"\r\n ],\r\n \"Note\": \"{{$randomLoremSentences}}\",\r\n \"InternalNote\": \"{{$randomLoremSentences}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/incident", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident" - ] - } - }, - "response": [] - }, - { - "name": "Get Incident", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/incident/FIR122020-12570", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident", - "FIR122020-12570" - ] - } - }, - "response": [] - }, - { - "name": "Get All Incidents", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/incident?limit=5", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident" - ], - "query": [ - { - "key": "limit", - "value": "5" - } - ] - } - }, - "response": [] - }, - { - "name": "Update Incident", - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"id\": \"FIR032020-12600\",\r\n \"clientId\": 3,\r\n \"foundationType\": 5,\r\n \"chainedBuilding\": {{$randomBoolean}},\r\n \"owner\": {{$randomBoolean}},\r\n \"foundationRecovery\": {{$randomBoolean}},\r\n \"neighborRecovery\": {{$randomBoolean}},\r\n \"foundationDamageCause\": 6,\r\n \"documentFile\": [\r\n \"https://somefile.ext\"\r\n ],\r\n \"note\": \"{{$randomLoremSentences}}\",\r\n \"internalNote\": \"{{$randomLoremSentences}}\",\r\n \"auditStatus\": 0,\r\n \"questionType\": 0,\r\n \"foundationDamageCharacteristics\": [\r\n 1,\r\n 3\r\n ],\r\n \"environmentDamageCharacteristics\": [\r\n 1\r\n ],\r\n \"email\": \"Kaylah.Wehner@yahoo.com\",\r\n \"name\": \"{{$randomFullName}}\",\r\n \"phoneNumber\": \"06360557722\",\r\n \"address\": \"gfm-00000163c7e04fa9a562688df1e077b9\",\r\n \"createDate\": \"2020-09-08T13:54:53.269121+00:00\",\r\n \"updateDate\": null,\r\n \"deleteDate\": null\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/incident/FIR122020-12570", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident", - "FIR122020-12570" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Portal", - "item": [ - { - "name": "Create Incident", - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"Name\": \"{{$randomFullName}}\",\r\n \"ClientId\": 3,\r\n \"Email\": \"{{$randomEmail}}\",\r\n \"PhoneNumber\": \"06360557722\",\r\n \"FoundationType\": 5,\r\n \"Address\": \"gfm-00000163c7e04fa9a562688df1e077b9\",\r\n \"FoundationDamageCharacteristics\": [\r\n 1,\r\n 3\r\n ],\r\n \"EnvironmentDamageCharacteristics\": [\r\n 1\r\n ],\r\n \"Owner\": {{$randomBoolean}},\r\n \"FoundationRecovery\": {{$randomBoolean}},\r\n \"NeighborRecovery\": {{$randomBoolean}},\r\n \"FoundationDamageCause\": 6,\r\n \"DocumentFile\": [\r\n \"https://somefile.ext\"\r\n ],\r\n \"Note\": \"{{$randomLoremSentences}}\",\r\n \"InternalNote\": \"{{$randomLoremSentences}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/incident-portal/submit", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident-portal", - "submit" - ] - } - }, - "response": [] - }, - { - "name": "Get Address Suggestions", - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/incident-portal/address-suggest?query=2628XG&limit=10", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident-portal", - "address-suggest" - ], - "query": [ - { - "key": "query", - "value": "2628XG" - }, - { - "key": "limit", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Upload Incident Document", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "pm.test(\"Body matches string\", function () {", - " pm.expect(pm.response.text()).to.include(\"name\");", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "input", - "type": "file", - "src": "/home/yorick/Downloads/dummy.pdf" - } - ] - }, - "url": { - "raw": "{{base_url}}/api/incident-portal/upload-document", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "incident-portal", - "upload-document" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Address", - "item": [ - { - "name": "Get Suggestions", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "if (pm.response.json().length > 0) {", - " pm.environment.set(\"address_id\", pm.response.json()[0][\"id\"])", - "}" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/address/suggest?query=3123EB&limit=20", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "address", - "suggest" - ], - "query": [ - { - "key": "query", - "value": "3123EB" - }, - { - "key": "limit", - "value": "20" - } - ] - } - }, - "response": [] - }, - { - "name": "Get address", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/address/{{address_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "address", - "{{address_id}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "User", - "item": [ - { - "name": "Get Current User", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/user", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "user" - ] - } - }, - "response": [] - }, - { - "name": "Update Current User", - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"id\": \"407988e2-e80c-4edd-85ab-2469c8beb15d\",\r\n \"givenName\": \"{{$randomFirstName}}\",\r\n \"lastName\": \"{{$randomLastName}}\",\r\n \"email\": \"{{username}}\",\r\n \"avatar\": null,\r\n \"jobTitle\": \"{{$randomJobTitle}}\",\r\n \"phoneNumber\": \"067634283\",\r\n \"role\": 1\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/user", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "user" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Organization", - "item": [ - { - "name": "Organization Setup", - "request": { - "method": "POST", - "header": [], - "url": { - "raw": "{{base_url}}/api/organization/setup", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "organization", - "setup" - ] - } - }, - "response": [] - }, - { - "name": "Get Current Organization [Session]", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/organization", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "organization" - ] - } - }, - "response": [] - }, - { - "name": "Update Current Organization [Session]", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"givenName\": \"{{$randomFirstName}}\",\r\n \"lastName\": \"{{$randomLastName}}\",\r\n \"email\": \"{{username}}\",\r\n \"avatar\": null,\r\n \"jobTitle\": \"{{$randomJobTitle}}\",\r\n \"phoneNumber\": null\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/organization/user", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "organization", - "user" - ] - } - }, - "response": [] - }, - { - "name": "Create Organization [Admin]", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"name\": \"Starbucks\",\r\n \"email\": \"info@starbucks.com\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/organization", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "organization" - ] - } - }, - "response": [] - }, - { - "name": "Organization Setup [Anon]", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"email\": \"{{username}}\",\r\n \"password\": \"{{password}}\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/organization/11cdc51f-3ba6-4e3c-b975-dfed4f054c31/setup", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "organization", - "11cdc51f-3ba6-4e3c-b975-dfed4f054c31", - "setup" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Auth", - "item": [ - { - "name": "SignIn", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "var jsonData = JSON.parse(responseBody);", - "pm.environment.set(\"bearer_token\", jsonData.token);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"Email\": \"{{username}}\",\r\n \"Password\": \"{{password}}\"\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/api/auth/signin", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "auth", - "signin" - ] - } - }, - "response": [] - }, - { - "name": "Refresh Token", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "var jsonData = JSON.parse(responseBody);", - "pm.environment.set(\"bearer_token\", jsonData.token);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/auth/token-refresh", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "auth", - "token-refresh" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Layer", - "item": [ - { - "name": "Get Layer", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/layer/{{layer_id}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "layer", - "{{layer_id}}" - ] - }, - "description": "Returns layer by id" - }, - "response": [] - }, - { - "name": "Get All Layers", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/layer", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "layer" - ] - }, - "description": "Returns all layers" - }, - "response": [] - } - ] - }, - { - "name": "Bundle", - "item": [ - { - "name": "Get All Bundles", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/bundle", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "bundle" - ] - }, - "description": "Gets all the bundles (scoped to organization)" - }, - "response": [] - } - ] - }, - { - "name": "Get Version", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "pm.test(\"Your test name\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.name).to.eql('FunderMaps');", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/version", - "host": [ - "{{base_url}}" - ], - "path": [ - "api", - "version" - ] - } - }, - "response": [] - } - ], - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{bearer_token}}", - "type": "string" - } - ] - }, - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "base_url", - "value": "" - }, - { - "key": "bearer_token", - "value": "" - } - ] -} \ No newline at end of file diff --git a/database/data/seed_application.sql b/database/data/seed_application.sql index e553759b7..8eb7c9f75 100644 --- a/database/data/seed_application.sql +++ b/database/data/seed_application.sql @@ -31,12 +31,13 @@ COPY application.organization (id, name, normalized_name, email, phone_number, b -- Data for Name: user; Type: TABLE DATA; Schema: application; Owner: fundermaps -- -COPY application."user" (id, given_name, last_name, email, normalized_email, email_confirmed, avatar, job_title, password_hash, phone_number, two_factor_enabled, lockout_end, access_failed_count, role, last_login, login_count, phone_number_confirmed) FROM stdin; -eda54685-a2c1-4d0e-98d8-d63faccc8a9f Administrator \N admin@fundermaps.com ADMIN@FUNDERMAPS.COM f \N Administrator AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== \N f \N 0 administrator \N 0 f -ff1ee265-29aa-4eff-beb1-cf02609a909c \N \N Javier40@yahoo.com JAVIER40@YAHOO.COM f \N \N AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== \N f \N 0 user \N 0 f -21c403fe-45fc-4106-9551-3aada1bbdec3 \N Kihn Freda@contoso.com FREDA@CONTOSO.COM f \N soldier AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== 80186700424 f \N 0 user \N 0 f -1a93cfb3-f097-4697-a998-71cdd9cfaead Lester Bednar lester@contoso.com LESTER@CONTOSO.COM f https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/373.jpg actor AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== 55505763052 f \N 0 user \N 0 f -aadc6b80-b447-443b-b4ed-fdfcb00976f2 Patsy Brekke patsy@contoso.com PATSY@CONTOSO.COM f \N decorator AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== 59539557702 f \N 0 user \N 0 f +COPY application."user" (id, given_name, last_name, email, normalized_email, email_confirmed, avatar, job_title, password_hash, phone_number, two_factor_enabled, access_failed_count, role, last_login, login_count, phone_number_confirmed) FROM stdin; +eda54685-a2c1-4d0e-98d8-d63faccc8a9f Administrator \N admin@fundermaps.com ADMIN@FUNDERMAPS.COM f \N Administrator AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== \N f 0 administrator \N 0 f +ff1ee265-29aa-4eff-beb1-cf02609a909c \N \N Javier40@yahoo.com JAVIER40@YAHOO.COM f \N \N AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== \N f 0 user \N 0 f +21c403fe-45fc-4106-9551-3aada1bbdec3 \N Kihn Freda@contoso.com FREDA@CONTOSO.COM f \N soldier AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== 80186700424 f 0 user \N 0 f +1a93cfb3-f097-4697-a998-71cdd9cfaead Lester Bednar lester@contoso.com LESTER@CONTOSO.COM f https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/373.jpg actor AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== 55505763052 f 0 user \N 0 f +aadc6b80-b447-443b-b4ed-fdfcb00976f2 Patsy Brekke patsy@contoso.com PATSY@CONTOSO.COM f \N decorator AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== 59539557702 f 0 user \N 0 f +ab403d16-e428-4a75-9eec-3dd08b294988 \N \N corene@contoso.com CORENE@CONTOSO.COM f \N \N AcoX6S+JSGn42iAC48JcoKYmWDUjWpb9jgbY92QvK9jTpU3G2EvFZNiU3rMUgHQ16g== \N f 0 user \N 0 f \. @@ -81,6 +82,7 @@ ff1ee265-29aa-4eff-beb1-cf02609a909c 05203318-6c55-43c1-a6a6-bb8c83f930c3 superu 21c403fe-45fc-4106-9551-3aada1bbdec3 05203318-6c55-43c1-a6a6-bb8c83f930c3 verifier aadc6b80-b447-443b-b4ed-fdfcb00976f2 05203318-6c55-43c1-a6a6-bb8c83f930c3 writer 1a93cfb3-f097-4697-a998-71cdd9cfaead 05203318-6c55-43c1-a6a6-bb8c83f930c3 reader +ab403d16-e428-4a75-9eec-3dd08b294988 05203318-6c55-43c1-a6a6-bb8c83f930c3 reader \. diff --git a/database/data/seed_maplayer.sql b/database/data/seed_maplayer.sql index 7fe44f4e6..dc24f9844 100644 --- a/database/data/seed_maplayer.sql +++ b/database/data/seed_maplayer.sql @@ -21,6 +21,7 @@ SET row_security = off; -- COPY maplayer.bundle (id, organization_id, name, create_date, update_date, delete_date, layer_configuration) FROM stdin; +a1537d6c-71c1-483b-978f-103450b9345e 05203318-6c55-43c1-a6a6-bb8c83f930c3 Gebouw 2021-03-26 09:05:29.2066+00 \N \N {"Layers": [{"LayerId": "c7ccf095-cf77-4f41-813a-68b493f7c6cb", "ColumnNames": ["id", "built_year", "geom"]}, {"LayerId": "782bc8e1-ff0f-48aa-9f0d-10232392ceda", "ColumnNames": ["id", "building_height", "geom"]}, {"LayerId": "22bcc8a3-fd28-4184-822b-f66e3e79e4b7", "ColumnNames": ["id", "velocity", "geom"]}, {"LayerId": "806d560e-2931-46d9-a06b-644491a335e8", "ColumnNames": ["id", "owner", "geom"]}]} \. @@ -37,7 +38,6 @@ c7ccf095-cf77-4f41-813a-68b493f7c6cb maplayer building_built_year Bouwjaar {"typ 5742df10-53fe-44da-b449-2c0c926deab6 maplayer incident Meldingen {"type": "color", "column": "meldingen123kleurtest", "values": {"color": "#bd6495"}} 307e6489-feb3-4be8-919c-4b5392fee8fb maplayer inquiry_sample_enforcement_term Handhavingstermijn (jaar) {"type": "range_num", "column": "enforcement_term", "values": [{"max": "100", "min": "25", "color": "#64DEBC", "label": "> 25"}, {"max": "25", "min": "20", "color": "#55E293", "label": "20 t/m 25"}, {"max": "20", "min": "15", "color": "#46E65F", "label": "15 t/m 20"}, {"max": "15", "min": "10", "color": "#4CEB36", "label": "10 t/m 15"}, {"max": "10", "min": "5", "color": "#77F025", "label": "5 t/m 10"}, {"max": "5", "min": "0", "color": "#AEF614", "label": "0 t/m 5"}, {"max": "0", "min": "-5", "color": "#D0E218", "label": " 0 t/m -5"}, {"max": "-5", "min": "-10", "color": "#CEB31B", "label": "-5 t/m -10"}, {"max": "-10", "min": "-15", "color": "#BB7F1E", "label": "-10 t/m -15"}, {"max": "-15", "min": "-20", "color": "#A85520", "label": "-15 t/m -20"}, {"max": "-20", "min": "-25", "color": "#973321", "label": "-20 t/m -25"}, {"max": "-25", "min": "-100", "color": "#86222A", "label": "< -25"}]} 75709b4f-d82e-4d62-9be3-07cb2ca00cec maplayer inquiry_sample_damage_cause Oorzaak Schade {"type": "case_multimatch", "column": "damage_cause", "values": [{"color": "#55B5A7", "label": "Ontwateringsdiepte", "match": ["drainage"]}, {"color": "#4B8FBF", "label": "Overbelasting", "match": ["overcharge"]}, {"color": "#4145C9", "label": "Bacteriële aantasting", "match": ["bio_fungus_infection", "bio_infection"]}, {"color": "#8936D4", "label": "Schimmelaantasting", "match": ["fungus_infection", "drystand", "bio_fungus_infection"]}, {"color": "#DE2CCF", "label": "Bodemdaling", "match": ["subsidence"]}, {"color": "#D2386F", "label": "Planten en wortels", "match": ["vegetation"]}, {"color": "#C75D43", "label": "Aardbeving", "match": ["gas", "vibrations"]}, {"color": "#BBA14F", "label": "Partieel funderingsherstel", "match": ["partial_foundation_recovery"]}, {"color": "#95B05A", "label": "Constructiefout", "match": ["construction_flaw", "foundation_flaw", "construction_heave"]}, {"color": "#6EA466", "label": "Negatieve kleef", "match": ["negative_cling", "overcharge_negative_cling"]}, {"color": "#6A6C70", "label": "Onbekend", "match": ["unknown"]}]} -782bc8e1-ff0f-48aa-9f0d-10232392ceda maplayer building_height Gebouwhoogte (Beta) \N 8beee1ea-9cd5-4999-8759-02e4cf313bd9 maplayer building_hotspot Hotspots {"type": "color", "column": "meldingen123kleurtest", "values": {"color": "#d11313"}} 16cc1db0-5f09-4673-9e07-e5ac573fc1b7 maplayer foundation_indicative Funderingstype Indicatief {"type": "case_multimatch", "column": "foundation_type", "values": [{"color": "#c75d43", "label": "Houten paal", "match": ["wood", "wood_rotterdam", "wood_amsterdam"]}, {"color": "#deb271", "label": "Houten paal met oplanger", "match": ["wood_charger"]}, {"color": "#6a6c70", "label": "Betonnen paal", "match": ["concrete"]}, {"color": "#ff3333", "label": "Op staal", "match": ["no_pile", "no_pile_masonry", "no_pile_strips", "no_pile_concrete_floor", "no_pile_slit", "no_pile_bearing_floor"]}]} 806d560e-2931-46d9-a06b-644491a335e8 maplayer building_ownership Eigendom {"type": "color", "column": "meldingen123kleurtest", "values": {"color": "#d11313"}} @@ -46,6 +46,7 @@ e0519b1a-ae1a-43ad-a2b9-bdbbeb0c5f86 maplayer incident_aggregate_category Incide dfe1a361-c23f-4a1d-ba49-af8e974270b3 maplayer subsidence_hex Maaiveldzakking {"type": "range_num", "column": "velocity", "values": [{"max": "9999", "min": "0", "color": "#f7fbff", "label": "> 0 mm/jaar"}, {"max": "0", "min": "-0.5", "color": "#d8e7f5", "label": "0,0 t/m -0,5 mm/jaar"}, {"max": "-0.5", "min": "-1", "color": "#b0d2e8", "label": "-0,5 t/m -1,0 mm/jaar"}, {"max": "-1", "min": "-1.5", "color": "#73b3d8", "label": "-1,0 t/m -1,5 mm/jaar"}, {"max": "-1.5", "min": "-2", "color": "#3e8ec4", "label": "-1,5 t/m -2,0 mm/jaar"}, {"max": "-2", "min": "-2.5", "color": "#1563aa", "label": "-2,0 t/m -2,5 mm/jaar"}, {"max": "-2.5", "min": "-9999", "color": "#08306b", "label": "< -2,5 mm/jaar"}]} f42a6826-c3a0-48b1-8c96-6c9ef753ed46 maplayer inquiry_sample_foundation_type Funderingstype vastgesteld {"type": "case_multimatch", "column": "foundation_type", "values": [{"color": "#c75d43", "label": "Houten paal", "match": ["wood", "weighted_pile", "wood_amsterdam", "wood_rotterdam"]}, {"color": "#deb271", "label": "Houten paal met oplanger", "match": ["wood_charger"]}, {"color": "#6a6c70", "label": "Betonnen paal", "match": ["concrete"]}, {"color": "#ff3333", "label": "Op staal", "match": ["no_pile", "no_pile_masonry", "no_pile_strips", "no_pile_concrete_floor", "no_pile_slit", "no_pile_bearing_floor"]}, {"color": "#bdbebf", "label": "Stalen paal", "match": ["steel_pile"]}, {"color": "#7192de", "label": "Verzwaarde betonpuntpaal", "match": ["weighted_pile"]}, {"color": "#b271de", "label": "Combinatie", "match": ["combined"]}, {"color": "#ffec33", "label": "Overig", "match": ["other"]}, {"color": "#71decc", "label": "Onbekend", "match": ["unknown"]}]} 9dffd130-4019-4440-b3d5-8812a961a87a maplayer recovery_sample_type Hesteld {"type": "case_multimatch", "column": "type", "values": [{"color": "#5cbe55", "label": "Volledig herstel", "match": ["table"]}, {"color": "#47baa5", "label": "Partieel herstel", "match": ["pile_in_wall"]}, {"color": "#8c4bb6", "label": "Paalkop verlaging", "match": ["pile_lowering", "beam_on_pile"]}, {"color": "#c67e70", "label": "Grondverbetering", "match": ["injection"]}, {"color": "#5B4AB7", "label": "Onbekend", "match": ["unknown"]}]} +782bc8e1-ff0f-48aa-9f0d-10232392ceda maplayer building_height Gebouwhoogte (Beta) {"type": "range_num", "column": "building_height", "values": [{"max": "5", "min": "0", "color": "#f7fbff", "label": "< 5m"}, {"max": "7", "min": "5", "color": "#d8e7f5", "label": "5 t/m 7m"}, {"max": "9", "min": "7", "color": "#b0d2e8", "label": "7 t/m 9m"}, {"max": "11", "min": "9", "color": "#73b3d8", "label": "9 t/m 11m"}, {"max": "13", "min": "11", "color": "#3e8ec4", "label": "11 t/m 13m"}, {"max": "15", "min": "13", "color": "#1563aa", "label": "13 t/m 15m"}, {"max": "17", "min": "15", "color": "#08306b", "label": "15 t/m 17m"}, {"max": "9999", "min": "17", "color": "#031229", "label": "> 17m"}]} \. diff --git a/database/data/seed_report.sql b/database/data/seed_report.sql index 564e3b217..727928241 100644 --- a/database/data/seed_report.sql +++ b/database/data/seed_report.sql @@ -47,22 +47,6 @@ COPY report.inquiry_sample (id, inquiry, address, create_date, update_date, dele \. --- --- Data for Name: project; Type: TABLE DATA; Schema: report; Owner: fundermaps --- - -COPY report.project (id, dossier, note, start_date, end_date, create_date, update_date, delete_date, adviser, creator, lead) FROM stdin; -\. - - --- --- Data for Name: project_sample; Type: TABLE DATA; Schema: report; Owner: fundermaps --- - -COPY report.project_sample (id, project, create_date, update_date, delete_date, note, status, contact, address) FROM stdin; -\. - - -- -- Data for Name: recovery; Type: TABLE DATA; Schema: report; Owner: fundermaps -- @@ -104,20 +88,6 @@ SELECT pg_catalog.setval('report.inquiry_id_seq', 10000, false); SELECT pg_catalog.setval('report.inquiry_sample_id_seq', 10000, false); --- --- Name: project_id_seq; Type: SEQUENCE SET; Schema: report; Owner: fundermaps --- - -SELECT pg_catalog.setval('report.project_id_seq', 10000, false); - - --- --- Name: project_sample_id_seq; Type: SEQUENCE SET; Schema: report; Owner: fundermaps --- - -SELECT pg_catalog.setval('report.project_sample_id_seq', 10000, false); - - -- -- Name: recovery_id_seq; Type: SEQUENCE SET; Schema: report; Owner: fundermaps -- diff --git a/database/fundermaps_base.sql b/database/fundermaps_base.sql index 6aeadafb5..e569aa661 100644 --- a/database/fundermaps_base.sql +++ b/database/fundermaps_base.sql @@ -824,34 +824,6 @@ ALTER TYPE report.pile_type OWNER TO fundermaps; COMMENT ON TYPE report.pile_type IS 'Enum representing the type of pile.'; --- --- Name: project_sample_status; Type: TYPE; Schema: report; Owner: fundermaps --- - -CREATE TYPE report.project_sample_status AS ENUM ( - 'contacted', - 'quotation_reserach', - 'research_in_progress', - 'research_pending', - 'research_canceled', - 'quotation_recovery', - 'waiting_on_permit', - 'recovery_in_progress', - 'recovery_pending', - 'recovery_canceled', - 'none' -); - - -ALTER TYPE report.project_sample_status OWNER TO fundermaps; - --- --- Name: TYPE project_sample_status; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON TYPE report.project_sample_status IS 'Enum representing the status of taking a sample for a project.'; - - -- -- Name: quality; Type: TYPE; Schema: report; Owner: fundermaps -- @@ -1264,25 +1236,6 @@ ALTER FUNCTION application.is_geometry_in_fence(user_id uuid, geom public.geomet COMMENT ON FUNCTION application.is_geometry_in_fence(user_id uuid, geom public.geometry) IS 'Validates whether or not a geometry intersects with the geofence of an organisation. Note that the specified id belongs to a user, not to an organization.'; --- --- Name: is_locked_out(application.user_id); Type: FUNCTION; Schema: application; Owner: fundermaps --- - -CREATE FUNCTION application.is_locked_out(id application.user_id) RETURNS boolean - LANGUAGE sql - AS $_$ -SELECT EXISTS ( - SELECT id - FROM application.user - WHERE id = $1 - AND lockout_end > NOW() - LIMIT 1 -) -;$_$; - - -ALTER FUNCTION application.is_locked_out(id application.user_id) OWNER TO fundermaps; - -- -- Name: log_access(application.user_id); Type: FUNCTION; Schema: application; Owner: fundermaps -- @@ -1651,7 +1604,6 @@ CREATE TABLE application."user" ( password_hash text, phone_number application.phone, two_factor_enabled boolean DEFAULT false NOT NULL, - lockout_end timestamp with time zone, access_failed_count integer DEFAULT 0 NOT NULL, role application.role DEFAULT 'user'::application.role NOT NULL, last_login timestamp with time zone, @@ -1849,6 +1801,7 @@ COMMENT ON VIEW geocoder.building_active IS 'Contains all entries from geocoder. CREATE MATERIALIZED VIEW data.analysis_foundation_indicative AS SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'concrete'::report.foundation_type AS foundation_type @@ -1860,6 +1813,7 @@ CREATE MATERIALIZED VIEW data.analysis_foundation_indicative AS WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) >= (1970)::double precision)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'no_pile'::report.foundation_type AS foundation_type @@ -1871,6 +1825,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (10.5)::double precision) AND (gr.code <> 'hz'::text)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'no_pile'::report.foundation_type AS foundation_type @@ -1882,6 +1837,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (10.5)::double precision) AND (gr.code = 'hz'::text)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'wood'::report.foundation_type AS foundation_type @@ -1893,6 +1849,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (10.5)::double precision) AND (gr.code = 'hz'::text)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'wood_charger'::report.foundation_type AS foundation_type @@ -1904,6 +1861,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (10.5)::double precision) AND (gr.code <> 'hz'::text)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'wood'::report.foundation_type AS foundation_type @@ -1915,6 +1873,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1925)::double precision) AND (bh.height >= (10.5)::double precision) AND (gr.code <> 'hz'::text)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'no_pile'::report.foundation_type AS foundation_type @@ -1926,6 +1885,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height < (10.5)::double precision)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'no_pile'::report.foundation_type AS foundation_type @@ -1937,6 +1897,7 @@ UNION ALL WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) < (1700)::double precision)) UNION ALL SELECT b.id, + b.neighborhood_id, bh.height, b.geom, 'wood'::report.foundation_type AS foundation_type @@ -1957,7 +1918,7 @@ ALTER TABLE data.analysis_foundation_indicative OWNER TO fundermaps; CREATE TABLE data.building_groundwater_level ( building_id geocoder.geocoder_id NOT NULL, - level double precision + level double precision NOT NULL ); @@ -1969,6 +1930,7 @@ ALTER TABLE data.building_groundwater_level OWNER TO fundermaps; CREATE MATERIALIZED VIEW data.analysis_foundation_risk AS SELECT b.id, + b.neighborhood_id, gr.code, gwl.level AS groundwater_level, b.geom, @@ -1982,6 +1944,7 @@ CREATE MATERIALIZED VIEW data.analysis_foundation_risk AS WHERE ((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) >= (1970)::double precision)) UNION ALL SELECT b.id, + b.neighborhood_id, gr.code, gwl.level AS groundwater_level, b.geom, @@ -1995,6 +1958,7 @@ UNION ALL WHERE (((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) < (1700)::double precision) AND (gwl.level > (0.6)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height < (9.5)::double precision) AND (gwl.level > (0.6)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height > (9.5)::double precision) AND (gwl.level < (1.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height >= (9.5)::double precision) AND (gwl.level < (1.5)::double precision) AND (s.velocity > (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level > (0.6)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height > (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level < (1.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level < (1.5)::double precision) AND (s.velocity > (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height > (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level < (2.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level < (2.5)::double precision) AND (s.velocity > (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1925)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level < (1.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1925)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level < (1.5)::double precision) AND (s.velocity > (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level > (0.6)::double precision) AND (s.velocity > (- (1)::double precision)))) UNION ALL SELECT b.id, + b.neighborhood_id, gr.code, gwl.level AS groundwater_level, b.geom, @@ -2008,6 +1972,7 @@ UNION ALL WHERE (((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) < (1700)::double precision) AND (gwl.level < (0.6)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) < (1700)::double precision) AND (gwl.level > (0.6)::double precision) AND (s.velocity > (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height < (9.5)::double precision) AND (gwl.level < (0.6)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height >= (9.5)::double precision) AND (gwl.level > (1.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level < (0.6)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level < (0.6)::double precision) AND (s.velocity > (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level > (1.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level > (2.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level > (2.5)::double precision) AND (s.velocity > (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level < (2.5)::double precision) AND (s.velocity < (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1925)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level > (1.5)::double precision) AND (s.velocity > (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1925)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level < (1.5)::double precision) AND (s.velocity < (- (2.0)::double precision)))) UNION ALL SELECT b.id, + b.neighborhood_id, gr.code, gwl.level AS groundwater_level, b.geom, @@ -2021,6 +1986,7 @@ UNION ALL WHERE (((bt.id IS NULL) AND (date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1925)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level > (1.5)::double precision) AND (s.velocity IS NULL)) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level > (0.6)::double precision)) OR ((date_part('year'::text, (b.built_year)::date) < (1700)::double precision) AND (gwl.level > (0.6)::double precision) AND (s.velocity < (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) < (1700)::double precision) AND (gwl.level < (0.6)::double precision) AND (s.velocity > (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height < (9.5)::double precision) AND (gwl.level < (0.6)::double precision) AND (s.velocity > (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height >= (9.5)::double precision) AND (gwl.level > (1.5)::double precision) AND (s.velocity > (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height >= (9.5)::double precision) AND (gwl.level < (1.5)::double precision) AND (s.velocity < (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height < (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level > (0.6)::double precision) AND (s.velocity < (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height > (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level > (1.5)::double precision) AND (s.velocity > (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1800)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code = 'hz'::text) AND (gwl.level < (1.5)::double precision) AND (s.velocity < (- (2.0)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1925)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1970)::double precision) AND (bh.height >= (9.5)::double precision) AND (gr.code <> 'hz'::text) AND (gwl.level > (2.5)::double precision) AND (s.velocity < (- (1)::double precision))) OR ((date_part('year'::text, (b.built_year)::date) > (1700)::double precision) AND (date_part('year'::text, (b.built_year)::date) < (1800)::double precision) AND (bh.height < (9.5)::double precision) AND (gwl.level > (0.6)::double precision) AND (s.velocity < (- (1)::double precision)))) UNION ALL SELECT b.id, + b.neighborhood_id, gr.code, gwl.level AS groundwater_level, b.geom, @@ -2037,30 +2003,6 @@ UNION ALL ALTER TABLE data.analysis_foundation_risk OWNER TO fundermaps; --- --- Name: neighborhood; Type: TABLE; Schema: geocoder; Owner: fundermaps --- - -CREATE TABLE geocoder.neighborhood ( - id geocoder.geocoder_id NOT NULL, - external_id text NOT NULL, - external_source geocoder.data_source NOT NULL, - district_id geocoder.geocoder_id NOT NULL, - name text NOT NULL, - water boolean NOT NULL, - geom public.geometry(MultiPolygon,4326) NOT NULL -); - - -ALTER TABLE geocoder.neighborhood OWNER TO fundermaps; - --- --- Name: TABLE neighborhood; Type: COMMENT; Schema: geocoder; Owner: fundermaps --- - -COMMENT ON TABLE geocoder.neighborhood IS 'Contains all neighborhoods in our own format.'; - - -- -- Name: inquiry; Type: TABLE; Schema: report; Owner: fundermaps -- @@ -2295,7 +2237,7 @@ CREATE VIEW data.analysis_address AS a.id AS address_id, a.external_id AS address_external_id, a.postal_code, - n.id AS neighborhood_id, + afr.neighborhood_id, afr.groundwater_level, afr.code AS soil, be.roof AS building_height, @@ -2350,9 +2292,8 @@ CREATE VIEW data.analysis_address AS NULL::text AS bio_infection, 'indicative'::data.reliability AS bio_infection_reliability, afr.foundation_risk AS bio_infection_risk - FROM ((((((((geocoder.address a + FROM (((((((geocoder.address a JOIN geocoder.building_active b ON (((a.building_id)::text = (b.id)::text))) - JOIN geocoder.neighborhood n ON (((b.neighborhood_id)::text = (n.id)::text))) JOIN data.analysis_foundation_indicative afi ON (((afi.id)::text = (b.id)::text))) JOIN data.analysis_foundation_risk afr ON (((afr.id)::text = (b.id)::text))) LEFT JOIN data.building_elevation be ON (((be.building_id)::text = (b.id)::text))) @@ -2488,12 +2429,11 @@ COMMENT ON VIEW data.statistics_product_data_collected IS 'Contains statistics o -- CREATE VIEW data.statistics_product_foundation_risk AS - SELECT ba.neighborhood_id, + SELECT afr.neighborhood_id, afr.foundation_risk, - (((count(afr.foundation_risk))::numeric / sum(count(afr.foundation_risk)) OVER (PARTITION BY ba.neighborhood_id)) * (100)::numeric) AS percentage - FROM (geocoder.building_active ba - JOIN data.analysis_foundation_risk afr ON (((afr.id)::text = (ba.id)::text))) - GROUP BY ba.neighborhood_id, afr.foundation_risk; + (((count(afr.foundation_risk))::numeric / sum(count(afr.foundation_risk)) OVER (PARTITION BY afr.neighborhood_id)) * (100)::numeric) AS percentage + FROM data.analysis_foundation_risk afr + GROUP BY afr.neighborhood_id, afr.foundation_risk; ALTER TABLE data.statistics_product_foundation_risk OWNER TO fundermaps; @@ -2503,12 +2443,11 @@ ALTER TABLE data.statistics_product_foundation_risk OWNER TO fundermaps; -- CREATE VIEW data.statistics_product_foundation_type AS - SELECT ba.neighborhood_id, + SELECT afi.neighborhood_id, afi.foundation_type, - (((count(afi.foundation_type))::numeric / sum(count(afi.foundation_type)) OVER (PARTITION BY ba.neighborhood_id)) * (100)::numeric) AS percentage - FROM (geocoder.building_active ba - JOIN data.analysis_foundation_indicative afi ON (((afi.id)::text = (ba.id)::text))) - GROUP BY ba.neighborhood_id, afi.foundation_type; + (((count(afi.foundation_type))::numeric / sum(count(afi.foundation_type)) OVER (PARTITION BY afi.neighborhood_id)) * (100)::numeric) AS percentage + FROM data.analysis_foundation_indicative afi + GROUP BY afi.neighborhood_id, afi.foundation_type; ALTER TABLE data.statistics_product_foundation_type OWNER TO fundermaps; @@ -2722,6 +2661,30 @@ ALTER TABLE geocoder.municipality OWNER TO fundermaps; COMMENT ON TABLE geocoder.municipality IS 'Contains all municipalities in our own format.'; +-- +-- Name: neighborhood; Type: TABLE; Schema: geocoder; Owner: fundermaps +-- + +CREATE TABLE geocoder.neighborhood ( + id geocoder.geocoder_id NOT NULL, + external_id text NOT NULL, + external_source geocoder.data_source NOT NULL, + district_id geocoder.geocoder_id NOT NULL, + name text NOT NULL, + water boolean NOT NULL, + geom public.geometry(MultiPolygon,4326) NOT NULL +); + + +ALTER TABLE geocoder.neighborhood OWNER TO fundermaps; + +-- +-- Name: TABLE neighborhood; Type: COMMENT; Schema: geocoder; Owner: fundermaps +-- + +COMMENT ON TABLE geocoder.neighborhood IS 'Contains all neighborhoods in our own format.'; + + -- -- Name: state; Type: TABLE; Schema: geocoder; Owner: fundermaps -- @@ -2754,9 +2717,10 @@ CREATE VIEW maplayer.building_built_year AS SELECT ba.id, ba.geom, (date_part('year'::text, COALESCE((( SELECT is2.built_year - FROM (geocoder.address addr + FROM ((geocoder.address addr JOIN report.inquiry_sample is2 ON (((is2.address)::text = (addr.id)::text))) - WHERE ((ba.id)::text = (addr.building_id)::text) + JOIN report.inquiry i ON ((i.id = is2.inquiry))) + WHERE (((ba.id)::text = (addr.building_id)::text) AND (i.document_date > (ba.built_year)::date)) ORDER BY COALESCE(is2.update_date, is2.create_date) DESC LIMIT 1))::date, (ba.built_year)::date)))::integer AS built_year FROM geocoder.building_active ba; @@ -2855,9 +2819,11 @@ CREATE VIEW maplayer.foundation_indicative AS afi.foundation_type FROM data.analysis_foundation_indicative afi WHERE (NOT ((afi.id)::text IN ( SELECT addr.building_id - FROM (report.inquiry_sample ris + FROM (((report.inquiry_sample ris + JOIN report.inquiry i ON ((i.id = ris.inquiry))) JOIN geocoder.address addr ON (((ris.address)::text = (addr.id)::text))) - WHERE ((ris.foundation_type IS NOT NULL) AND (addr.building_id IS NOT NULL)) + JOIN geocoder.building_active ba ON (((addr.building_id)::text = (ba.id)::text))) + WHERE ((ris.foundation_type IS NOT NULL) AND (i.document_date > (ba.built_year)::date)) UNION SELECT addr.building_id FROM (report.recovery_sample rs @@ -2956,11 +2922,13 @@ CREATE VIEW maplayer.inquiry AS SELECT ris.id, i.id AS inquiry_id, i.type, - ab.geom, - row_number() OVER (PARTITION BY ab.building_id ORDER BY i.document_date DESC) AS rank - FROM ((report.inquiry_sample ris - JOIN geocoder.address_building ab ON (((ris.address)::text = (ab.address_id)::text))) + ba.geom, + row_number() OVER (PARTITION BY ba.id ORDER BY i.document_date DESC) AS rank + FROM (((report.inquiry_sample ris + JOIN geocoder.address addr ON (((ris.address)::text = (addr.id)::text))) + JOIN geocoder.building_active ba ON (((addr.building_id)::text = (ba.id)::text))) JOIN report.inquiry i ON ((i.id = ris.inquiry))) + WHERE (i.document_date > (ba.built_year)::date) ) SELECT ik.id, ik.inquiry_id, @@ -2980,13 +2948,15 @@ CREATE VIEW maplayer.inquiry_sample_damage_cause AS WITH inquiry_sample_rank AS ( SELECT ris.id, i.id AS inquiry_id, - ab.geom, + ba.geom, ris.damage_cause, ris.foundation_type, - row_number() OVER (PARTITION BY ab.building_id ORDER BY i.document_date DESC) AS rank - FROM ((report.inquiry_sample ris - JOIN geocoder.address_building ab ON (((ris.address)::text = (ab.address_id)::text))) + row_number() OVER (PARTITION BY ba.id ORDER BY i.document_date DESC) AS rank + FROM (((report.inquiry_sample ris + JOIN geocoder.address addr ON (((ris.address)::text = (addr.id)::text))) + JOIN geocoder.building_active ba ON (((addr.building_id)::text = (ba.id)::text))) JOIN report.inquiry i ON ((i.id = ris.inquiry))) + WHERE (i.document_date > (ba.built_year)::date) ) SELECT ik.id, ik.inquiry_id, @@ -3006,7 +2976,7 @@ CREATE VIEW maplayer.inquiry_sample_enforcement_term AS WITH inquiry_sample_rank AS ( SELECT ris.id, i.id AS inquiry_id, - ab.geom, + ba.geom, date_part('years'::text, age(( CASE ris.enforcement_term WHEN 'term05'::report.enforcement_term THEN (i.document_date + '5 years'::interval) @@ -3021,11 +2991,12 @@ CREATE VIEW maplayer.inquiry_sample_enforcement_term AS WHEN 'term40'::report.enforcement_term THEN (i.document_date + '40 years'::interval) ELSE NULL::timestamp without time zone END)::timestamp with time zone, CURRENT_TIMESTAMP)) AS enforcement_term, - row_number() OVER (PARTITION BY ab.building_id ORDER BY i.document_date DESC) AS rank - FROM ((report.inquiry_sample ris - JOIN geocoder.address_building ab ON (((ris.address)::text = (ab.address_id)::text))) + row_number() OVER (PARTITION BY ba.id ORDER BY i.document_date DESC) AS rank + FROM (((report.inquiry_sample ris + JOIN geocoder.address addr ON (((ris.address)::text = (addr.id)::text))) + JOIN geocoder.building_active ba ON (((addr.building_id)::text = (ba.id)::text))) JOIN report.inquiry i ON ((i.id = ris.inquiry))) - WHERE (ris.enforcement_term IS NOT NULL) + WHERE ((ris.enforcement_term IS NOT NULL) AND (i.document_date > (ba.built_year)::date)) ) SELECT ik.id, ik.inquiry_id, @@ -3045,14 +3016,15 @@ CREATE VIEW maplayer.inquiry_sample_foundation_type AS WITH inquiry_sample_rank AS ( SELECT ris.id, i.id AS inquiry_id, - ab.geom, + ba.geom, ris.foundation_type, - row_number() OVER (PARTITION BY ab.building_id ORDER BY i.document_date DESC) AS rank - FROM ((report.inquiry_sample ris - JOIN geocoder.address_building ab ON (((ris.address)::text = (ab.address_id)::text))) + row_number() OVER (PARTITION BY ba.id ORDER BY i.document_date DESC) AS rank + FROM (((report.inquiry_sample ris + JOIN geocoder.address addr ON (((ris.address)::text = (addr.id)::text))) + JOIN geocoder.building_active ba ON (((addr.building_id)::text = (ba.id)::text))) JOIN report.inquiry i ON ((i.id = ris.inquiry))) - WHERE ((ris.foundation_type IS NOT NULL) AND (NOT ((ris.address)::text IN ( SELECT recovery_sample.address - FROM report.recovery_sample)))) + WHERE ((ris.foundation_type IS NOT NULL) AND (NOT ((addr.id)::text IN ( SELECT recovery_sample.address + FROM report.recovery_sample))) AND (i.document_date > (ba.built_year)::date)) ) SELECT ik.id, ik.inquiry_id, @@ -3072,13 +3044,14 @@ CREATE VIEW maplayer.inquiry_sample_quality AS WITH inquiry_sample_rank AS ( SELECT ris.id, i.id AS inquiry_id, - ab.geom, + ba.geom, ris.overall_quality, - row_number() OVER (PARTITION BY ab.building_id ORDER BY i.document_date DESC) AS rank - FROM ((report.inquiry_sample ris - JOIN geocoder.address_building ab ON (((ris.address)::text = (ab.address_id)::text))) + row_number() OVER (PARTITION BY ba.id ORDER BY i.document_date DESC) AS rank + FROM (((report.inquiry_sample ris + JOIN geocoder.address addr ON (((ris.address)::text = (addr.id)::text))) + JOIN geocoder.building_active ba ON (((addr.building_id)::text = (ba.id)::text))) JOIN report.inquiry i ON ((i.id = ris.inquiry))) - WHERE (ris.overall_quality IS NOT NULL) + WHERE ((ris.overall_quality IS NOT NULL) AND (i.document_date > (ba.built_year)::date)) ) SELECT ik.id, ik.inquiry_id, @@ -3271,154 +3244,6 @@ ALTER TABLE report.inquiry_sample_id_seq OWNER TO fundermaps; ALTER SEQUENCE report.inquiry_sample_id_seq OWNED BY report.inquiry_sample.id; --- --- Name: project; Type: TABLE; Schema: report; Owner: fundermaps --- - -CREATE TABLE report.project ( - id integer NOT NULL, - dossier text, - note text, - start_date date NOT NULL, - end_date date, - create_date timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - update_date timestamp with time zone, - delete_date timestamp with time zone, - adviser application.user_id, - creator application.user_id, - lead application.user_id, - CONSTRAINT project_range_chk CHECK ((end_date > start_date)) -); - - -ALTER TABLE report.project OWNER TO fundermaps; - --- --- Name: TABLE project; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON TABLE report.project IS 'Contains projects.'; - - --- --- Name: COLUMN project.dossier; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project.dossier IS 'User provided dossier number, must be unique'; - - --- --- Name: COLUMN project.create_date; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project.create_date IS 'Timestamp of record creation, set by insert'; - - --- --- Name: COLUMN project.update_date; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project.update_date IS 'Timestamp of last record update, automatically updated on record modification'; - - --- --- Name: COLUMN project.delete_date; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project.delete_date IS 'Timestamp of soft delete'; - - --- --- Name: project_id_seq; Type: SEQUENCE; Schema: report; Owner: fundermaps --- - -CREATE SEQUENCE report.project_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE report.project_id_seq OWNER TO fundermaps; - --- --- Name: project_id_seq; Type: SEQUENCE OWNED BY; Schema: report; Owner: fundermaps --- - -ALTER SEQUENCE report.project_id_seq OWNED BY report.project.id; - - --- --- Name: project_sample; Type: TABLE; Schema: report; Owner: fundermaps --- - -CREATE TABLE report.project_sample ( - id integer NOT NULL, - project integer NOT NULL, - create_date timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - update_date timestamp with time zone, - delete_date timestamp with time zone, - note text, - status report.project_sample_status DEFAULT 'none'::report.project_sample_status NOT NULL, - contact text, - address geocoder.geocoder_id NOT NULL -); - - -ALTER TABLE report.project_sample OWNER TO fundermaps; - --- --- Name: TABLE project_sample; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON TABLE report.project_sample IS 'Contains sample data for projects.'; - - --- --- Name: COLUMN project_sample.create_date; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project_sample.create_date IS 'Timestamp of record creation, set by insert'; - - --- --- Name: COLUMN project_sample.update_date; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project_sample.update_date IS 'Timestamp of last record update, automatically updated on record modification'; - - --- --- Name: COLUMN project_sample.delete_date; Type: COMMENT; Schema: report; Owner: fundermaps --- - -COMMENT ON COLUMN report.project_sample.delete_date IS 'Timestamp of soft delete'; - - --- --- Name: project_sample_id_seq; Type: SEQUENCE; Schema: report; Owner: fundermaps --- - -CREATE SEQUENCE report.project_sample_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE report.project_sample_id_seq OWNER TO fundermaps; - --- --- Name: project_sample_id_seq; Type: SEQUENCE OWNED BY; Schema: report; Owner: fundermaps --- - -ALTER SEQUENCE report.project_sample_id_seq OWNED BY report.project_sample.id; - - -- -- Name: recovery_id_seq; Type: SEQUENCE; Schema: report; Owner: fundermaps -- @@ -3484,20 +3309,6 @@ ALTER TABLE ONLY report.inquiry ALTER COLUMN id SET DEFAULT nextval('report.inqu ALTER TABLE ONLY report.inquiry_sample ALTER COLUMN id SET DEFAULT nextval('report.inquiry_sample_id_seq'::regclass); --- --- Name: project id; Type: DEFAULT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project ALTER COLUMN id SET DEFAULT nextval('report.project_id_seq'::regclass); - - --- --- Name: project_sample id; Type: DEFAULT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project_sample ALTER COLUMN id SET DEFAULT nextval('report.project_sample_id_seq'::regclass); - - -- -- Name: recovery id; Type: DEFAULT; Schema: report; Owner: fundermaps -- @@ -3704,30 +3515,6 @@ ALTER TABLE ONLY report.inquiry_sample ADD CONSTRAINT inquiry_sample_pkey PRIMARY KEY (id); --- --- Name: project project_dossier_key; Type: CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project - ADD CONSTRAINT project_dossier_key UNIQUE (dossier); - - --- --- Name: project project_pkey; Type: CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project - ADD CONSTRAINT project_pkey PRIMARY KEY (id); - - --- --- Name: project_sample project_sample_pkey; Type: CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project_sample - ADD CONSTRAINT project_sample_pkey PRIMARY KEY (id); - - -- -- Name: recovery recovery_pkey; Type: CONSTRAINT; Schema: report; Owner: fundermaps -- @@ -3755,7 +3542,7 @@ CREATE INDEX organization_fence_idx ON application.organization USING gist (fenc -- Name: organization_normalized_email_idx; Type: INDEX; Schema: application; Owner: fundermaps -- -CREATE UNIQUE INDEX organization_normalized_email_idx ON application.organization USING btree (normalized_email) WHERE (normalized_email IS NOT NULL); +CREATE UNIQUE INDEX organization_normalized_email_idx ON application.organization USING btree (normalized_email); -- @@ -3769,7 +3556,7 @@ CREATE INDEX organization_proposal_normalized_email_idx ON application.organizat -- Name: user_normalized_email_idx; Type: INDEX; Schema: application; Owner: fundermaps -- -CREATE UNIQUE INDEX user_normalized_email_idx ON application."user" USING btree (normalized_email) WHERE (normalized_email IS NOT NULL); +CREATE UNIQUE INDEX user_normalized_email_idx ON application."user" USING btree (normalized_email); -- @@ -3786,6 +3573,13 @@ CREATE INDEX analysis_foundation_indicative_foundation_type_idx ON data.analysis CREATE INDEX analysis_foundation_indicative_id_idx ON data.analysis_foundation_indicative USING btree (id); +-- +-- Name: analysis_foundation_indicative_neighborhood_id_idx; Type: INDEX; Schema: data; Owner: fundermaps +-- + +CREATE INDEX analysis_foundation_indicative_neighborhood_id_idx ON data.analysis_foundation_indicative USING btree (neighborhood_id); + + -- -- Name: analysis_foundation_risk_id_idx; Type: INDEX; Schema: data; Owner: fundermaps -- @@ -3793,6 +3587,20 @@ CREATE INDEX analysis_foundation_indicative_id_idx ON data.analysis_foundation_i CREATE INDEX analysis_foundation_risk_id_idx ON data.analysis_foundation_risk USING btree (id); +-- +-- Name: analysis_foundation_risk_neighborhood_id_idx; Type: INDEX; Schema: data; Owner: fundermaps +-- + +CREATE INDEX analysis_foundation_risk_neighborhood_id_idx ON data.analysis_foundation_risk USING btree (neighborhood_id); + + +-- +-- Name: building_elevation_available_idx; Type: INDEX; Schema: data; Owner: fundermaps +-- + +CREATE INDEX building_elevation_available_idx ON data.building_elevation USING btree (building_id) WHERE ((roof IS NOT NULL) AND (ground IS NOT NULL)); + + -- -- Name: building_type_id_idx; Type: INDEX; Schema: data; Owner: fundermaps -- @@ -3856,6 +3664,13 @@ CREATE UNIQUE INDEX address_external_id_source_idx ON geocoder.address USING btr CREATE INDEX address_streetname_idx ON geocoder.address USING btree (lower(street)); +-- +-- Name: building_active_idx; Type: INDEX; Schema: geocoder; Owner: fundermaps +-- + +CREATE INDEX building_active_idx ON geocoder.building USING btree (id) WHERE (is_active AND (geom IS NOT NULL)); + + -- -- Name: building_construction_year_idx; Type: INDEX; Schema: geocoder; Owner: fundermaps -- @@ -3877,6 +3692,13 @@ CREATE UNIQUE INDEX building_external_id_source_idx ON geocoder.building USING b CREATE INDEX building_geom_idx ON geocoder.building USING gist (geom); +-- +-- Name: building_neighborhood_active_idx; Type: INDEX; Schema: geocoder; Owner: fundermaps +-- + +CREATE INDEX building_neighborhood_active_idx ON geocoder.building USING btree (neighborhood_id) WHERE (is_active AND (geom IS NOT NULL)); + + -- -- Name: building_neighborhood_idx; Type: INDEX; Schema: geocoder; Owner: fundermaps -- @@ -4031,6 +3853,13 @@ CREATE INDEX inquiry_access_policy_idx ON report.inquiry USING btree (access_pol CREATE INDEX inquiry_document_date_idx ON report.inquiry USING btree (document_date); +-- +-- Name: inquiry_sample_address_idx; Type: INDEX; Schema: report; Owner: fundermaps +-- + +CREATE INDEX inquiry_sample_address_idx ON report.inquiry_sample USING btree (address); + + -- -- Name: inquiry_type_idx; Type: INDEX; Schema: report; Owner: fundermaps -- @@ -4045,6 +3874,13 @@ CREATE INDEX inquiry_type_idx ON report.inquiry USING btree (type); CREATE INDEX recovery_access_policy_idx ON report.recovery USING btree (access_policy); +-- +-- Name: recovery_sample_address_idx; Type: INDEX; Schema: report; Owner: fundermaps +-- + +CREATE INDEX recovery_sample_address_idx ON report.recovery_sample USING btree (address); + + -- -- Name: recovery_sample_pile_type_idx; Type: INDEX; Schema: report; Owner: fundermaps -- @@ -4108,20 +3944,6 @@ CREATE TRIGGER update_date_record BEFORE UPDATE ON report.inquiry FOR EACH ROW E CREATE TRIGGER update_date_record BEFORE UPDATE ON report.inquiry_sample FOR EACH ROW EXECUTE FUNCTION report.last_record_update(); --- --- Name: project update_date_record; Type: TRIGGER; Schema: report; Owner: fundermaps --- - -CREATE TRIGGER update_date_record BEFORE UPDATE ON report.project FOR EACH ROW EXECUTE FUNCTION report.last_record_update(); - - --- --- Name: project_sample update_date_record; Type: TRIGGER; Schema: report; Owner: fundermaps --- - -CREATE TRIGGER update_date_record BEFORE UPDATE ON report.project_sample FOR EACH ROW EXECUTE FUNCTION report.last_record_update(); - - -- -- Name: recovery update_date_record; Type: TRIGGER; Schema: report; Owner: fundermaps -- @@ -4320,54 +4142,6 @@ ALTER TABLE ONLY report.inquiry_sample ADD CONSTRAINT inquiry_sample_inquiry_fkey FOREIGN KEY (inquiry) REFERENCES report.inquiry(id) ON UPDATE CASCADE ON DELETE CASCADE; --- --- Name: project project_adviser_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project - ADD CONSTRAINT project_adviser_fkey FOREIGN KEY (adviser) REFERENCES application."user"(id) ON UPDATE CASCADE ON DELETE SET NULL; - - --- --- Name: project project_creator_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project - ADD CONSTRAINT project_creator_fkey FOREIGN KEY (creator) REFERENCES application."user"(id) ON UPDATE CASCADE ON DELETE SET NULL; - - --- --- Name: project project_lead_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project - ADD CONSTRAINT project_lead_fkey FOREIGN KEY (lead) REFERENCES application."user"(id) ON UPDATE CASCADE ON DELETE SET NULL; - - --- --- Name: project_sample project_sample_address_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project_sample - ADD CONSTRAINT project_sample_address_fkey FOREIGN KEY (address) REFERENCES geocoder.address(id) ON UPDATE CASCADE ON DELETE RESTRICT; - - --- --- Name: project_sample project_sample_contact_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project_sample - ADD CONSTRAINT project_sample_contact_fkey FOREIGN KEY (contact) REFERENCES application.contact(email) ON UPDATE CASCADE ON DELETE RESTRICT; - - --- --- Name: project_sample project_sample_project_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps --- - -ALTER TABLE ONLY report.project_sample - ADD CONSTRAINT project_sample_project_fkey FOREIGN KEY (project) REFERENCES report.project(id) ON UPDATE CASCADE ON DELETE CASCADE; - - -- -- Name: recovery recovery_attribution_fkey; Type: FK CONSTRAINT; Schema: report; Owner: fundermaps -- @@ -4722,14 +4496,6 @@ GRANT ALL ON TYPE report.pile_type TO fundermaps_webapp; GRANT ALL ON TYPE report.pile_type TO fundermaps_webservice; --- --- Name: TYPE project_sample_status; Type: ACL; Schema: report; Owner: fundermaps --- - -GRANT ALL ON TYPE report.project_sample_status TO fundermaps_webapp; -GRANT ALL ON TYPE report.project_sample_status TO fundermaps_webservice; - - -- -- Name: TYPE quality; Type: ACL; Schema: report; Owner: fundermaps -- @@ -4877,14 +4643,6 @@ GRANT ALL ON FUNCTION application.is_geometry_in_fence(user_id uuid, geom public GRANT ALL ON FUNCTION application.is_geometry_in_fence(user_id uuid, geom public.geometry) TO fundermaps_batch; --- --- Name: FUNCTION is_locked_out(id application.user_id); Type: ACL; Schema: application; Owner: fundermaps --- - -GRANT ALL ON FUNCTION application.is_locked_out(id application.user_id) TO fundermaps_webservice; -GRANT ALL ON FUNCTION application.is_locked_out(id application.user_id) TO pg_execute_server_program; - - -- -- Name: FUNCTION log_access(id application.user_id); Type: ACL; Schema: application; Owner: fundermaps -- @@ -5125,16 +4883,6 @@ GRANT SELECT ON TABLE data.analysis_foundation_risk TO fundermaps_webapp; GRANT SELECT ON TABLE data.analysis_foundation_risk TO fundermaps_webservice; --- --- Name: TABLE neighborhood; Type: ACL; Schema: geocoder; Owner: fundermaps --- - -GRANT SELECT,REFERENCES,TRIGGER ON TABLE geocoder.neighborhood TO fundermaps_webapp; -GRANT SELECT,REFERENCES,TRIGGER ON TABLE geocoder.neighborhood TO fundermaps_webservice; -GRANT SELECT,REFERENCES ON TABLE geocoder.neighborhood TO fundermaps_portal; -GRANT SELECT,REFERENCES ON TABLE geocoder.neighborhood TO fundermaps_batch; - - -- -- Name: TABLE inquiry; Type: ACL; Schema: report; Owner: fundermaps -- @@ -5296,6 +5044,16 @@ GRANT SELECT,REFERENCES ON TABLE geocoder.municipality TO fundermaps_portal; GRANT SELECT,REFERENCES ON TABLE geocoder.municipality TO fundermaps_batch; +-- +-- Name: TABLE neighborhood; Type: ACL; Schema: geocoder; Owner: fundermaps +-- + +GRANT SELECT,REFERENCES,TRIGGER ON TABLE geocoder.neighborhood TO fundermaps_webapp; +GRANT SELECT,REFERENCES,TRIGGER ON TABLE geocoder.neighborhood TO fundermaps_webservice; +GRANT SELECT,REFERENCES ON TABLE geocoder.neighborhood TO fundermaps_portal; +GRANT SELECT,REFERENCES ON TABLE geocoder.neighborhood TO fundermaps_batch; + + -- -- Name: TABLE state; Type: ACL; Schema: geocoder; Owner: fundermaps -- @@ -5474,36 +5232,6 @@ GRANT SELECT,USAGE ON SEQUENCE report.inquiry_sample_id_seq TO fundermaps_webser GRANT SELECT,USAGE ON SEQUENCE report.inquiry_sample_id_seq TO fundermaps_portal; --- --- Name: TABLE project; Type: ACL; Schema: report; Owner: fundermaps --- - -GRANT SELECT,INSERT,REFERENCES,DELETE,TRIGGER,UPDATE ON TABLE report.project TO fundermaps_webapp; - - --- --- Name: SEQUENCE project_id_seq; Type: ACL; Schema: report; Owner: fundermaps --- - -GRANT ALL ON SEQUENCE report.project_id_seq TO fundermaps_webapp; -GRANT SELECT,USAGE ON SEQUENCE report.project_id_seq TO fundermaps_webservice; - - --- --- Name: TABLE project_sample; Type: ACL; Schema: report; Owner: fundermaps --- - -GRANT SELECT,INSERT,REFERENCES,DELETE,TRIGGER,UPDATE ON TABLE report.project_sample TO fundermaps_webapp; - - --- --- Name: SEQUENCE project_sample_id_seq; Type: ACL; Schema: report; Owner: fundermaps --- - -GRANT ALL ON SEQUENCE report.project_sample_id_seq TO fundermaps_webapp; -GRANT SELECT,USAGE ON SEQUENCE report.project_sample_id_seq TO fundermaps_webservice; - - -- -- Name: SEQUENCE recovery_id_seq; Type: ACL; Schema: report; Owner: fundermaps -- diff --git a/database/data/precompute.sql b/database/precompute.sql similarity index 100% rename from database/data/precompute.sql rename to database/precompute.sql diff --git a/scripts/loaddb.sh b/scripts/loaddb.sh index f571a6d70..3f266c007 100755 --- a/scripts/loaddb.sh +++ b/scripts/loaddb.sh @@ -20,4 +20,4 @@ psql -h localhost -U postgres -d fundermaps -v ON_ERROR_STOP=1 < database/data/s psql -h localhost -U postgres -d fundermaps -v ON_ERROR_STOP=1 < database/data/seed_data.sql psql -h localhost -U postgres -d fundermaps -v ON_ERROR_STOP=1 < database/data/seed_maplayer.sql psql -h localhost -U postgres -d fundermaps -v ON_ERROR_STOP=1 < database/data/seed_report.sql -psql -h localhost -U postgres -d fundermaps -v ON_ERROR_STOP=1 < database/data/precompute.sql +psql -h localhost -U postgres -d fundermaps -v ON_ERROR_STOP=1 < database/precompute.sql diff --git a/src/FunderMaps.AspNetCore/HealthChecks/RepositoryHealthCheck.cs b/src/FunderMaps.AspNetCore/HealthChecks/RepositoryHealthCheck.cs index 8fa6274f0..6776e1e36 100644 --- a/src/FunderMaps.AspNetCore/HealthChecks/RepositoryHealthCheck.cs +++ b/src/FunderMaps.AspNetCore/HealthChecks/RepositoryHealthCheck.cs @@ -25,7 +25,7 @@ public RepositoryHealthCheck(ITestRepository testRepository) /// A System.Threading.CancellationToken that can be used to cancel the health check. /// Instance of . public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken) - => await _testRepository.IsAlive() + => await _testRepository.IsAliveAsync() ? HealthCheckResult.Healthy() : HealthCheckResult.Unhealthy(); } diff --git a/src/FunderMaps.AspNetCore/Services/SignInService.cs b/src/FunderMaps.AspNetCore/Services/SignInService.cs index b46a6e242..6bbd9538a 100644 --- a/src/FunderMaps.AspNetCore/Services/SignInService.cs +++ b/src/FunderMaps.AspNetCore/Services/SignInService.cs @@ -95,7 +95,7 @@ public virtual async Task SetPasswordAsync(Guid id, string password) /// /// The principal to sign in. /// Instance of . - public virtual async Task SignInAsync(ClaimsPrincipal principal) + public virtual ValueTask SignInAsync(ClaimsPrincipal principal) { if (principal is null) { @@ -114,19 +114,12 @@ public virtual async Task SignInAsync(ClaimsPrincipal principal) throw new AuthenticationException(); } - if (await UserRepository.IsLockedOutAsync(user.Id)) - { - Logger.LogWarning($"User '{user}' is currently locked out."); - - throw new AuthenticationException(); - } - Logger.LogTrace($"User '{user}' sign in was successful."); principal = PrincipalProvider.CreateTenantUserPrincipal(user, tenant, Enum.Parse(claim.Value), JwtBearerDefaults.AuthenticationScheme); - return TokenProvider.GetTokenContext(principal); + return new(TokenProvider.GetTokenContext(principal)); } /// @@ -137,19 +130,11 @@ public virtual async Task SignInAsync(ClaimsPrincipal principal) /// Instance of . public virtual async Task PasswordSignInAsync(string email, string password) { - IUser user = await UserRepository.GetByEmailAsync(email); - if (user is null) + if (await UserRepository.GetByEmailAsync(email) is not IUser user) { throw new AuthenticationException(); } - if (await UserRepository.IsLockedOutAsync(user.Id)) - { - Logger.LogWarning($"User '{user}' is currently locked out."); - - throw new AuthenticationException(); - } - // FUTURE: Single call? var organizationId = await OrganizationUserRepository.GetOrganizationByUserIdAsync(user.Id); Organization organization = await OrganizationRepository.GetByIdAsync(organizationId); diff --git a/src/FunderMaps.Core/Abstractions/AppServiceBase.cs b/src/FunderMaps.Core/Abstractions/AppServiceBase.cs index 2651775e4..f3575744c 100644 --- a/src/FunderMaps.Core/Abstractions/AppServiceBase.cs +++ b/src/FunderMaps.Core/Abstractions/AppServiceBase.cs @@ -1,6 +1,5 @@ namespace FunderMaps.Core.Abstractions { - // TODO: Add Logging ? /// /// Application service base. /// diff --git a/src/FunderMaps.Core/AppContext.cs b/src/FunderMaps.Core/AppContext.cs index d4bb3d76b..5bd42d920 100644 --- a/src/FunderMaps.Core/AppContext.cs +++ b/src/FunderMaps.Core/AppContext.cs @@ -7,8 +7,6 @@ namespace FunderMaps.Core { - // TODO: - // - Culture /// /// Application context to the entire application. /// diff --git a/src/FunderMaps.Core/Entities/AccessControl.cs b/src/FunderMaps.Core/Entities/AccessControl.cs index 2d6c3af29..5bbc6a0db 100644 --- a/src/FunderMaps.Core/Entities/AccessControl.cs +++ b/src/FunderMaps.Core/Entities/AccessControl.cs @@ -3,7 +3,6 @@ namespace FunderMaps.Core.Entities { - // TODO: Remove // FUTURE: Remove in the long term. /// /// Record control. diff --git a/src/FunderMaps.Core/Entities/Incident.cs b/src/FunderMaps.Core/Entities/Incident.cs index e62f7f9f7..e5d4a2dae 100644 --- a/src/FunderMaps.Core/Entities/Incident.cs +++ b/src/FunderMaps.Core/Entities/Incident.cs @@ -5,7 +5,6 @@ namespace FunderMaps.Core.Entities { - // TODO inherit from StateControl? /// /// Indicent entity. /// @@ -35,7 +34,7 @@ public Incident() /// Foundation type. /// [EnumDataType(typeof(FoundationType))] - public FoundationType FoundationType { get; set; } + public FoundationType? FoundationType { get; set; } /// /// Building chained to another building. diff --git a/src/FunderMaps.Core/Entities/Organization.cs b/src/FunderMaps.Core/Entities/Organization.cs index 2051bf7e9..d41658132 100644 --- a/src/FunderMaps.Core/Entities/Organization.cs +++ b/src/FunderMaps.Core/Entities/Organization.cs @@ -45,9 +45,6 @@ public Organization() /// public string BrandingLogo { get; set; } - // TODO: Convert to geocoder address? - // TODO: Drop the PO box? - /// /// Street. /// diff --git a/src/FunderMaps.Core/Entities/Project.cs b/src/FunderMaps.Core/Entities/Project.cs index f11e6ff37..35d92ec2d 100644 --- a/src/FunderMaps.Core/Entities/Project.cs +++ b/src/FunderMaps.Core/Entities/Project.cs @@ -3,7 +3,6 @@ namespace FunderMaps.Core.Entities { - // TODO inherit from StateControl? /// /// Project entity. /// diff --git a/src/FunderMaps.Core/Entities/ProjectSample.cs b/src/FunderMaps.Core/Entities/ProjectSample.cs deleted file mode 100644 index db30a2880..000000000 --- a/src/FunderMaps.Core/Entities/ProjectSample.cs +++ /dev/null @@ -1,67 +0,0 @@ -using FunderMaps.Core.DataAnnotations; -using FunderMaps.Core.Types; -using System.ComponentModel.DataAnnotations; - -namespace FunderMaps.Core.Entities -{ - /// - /// Project sample entity. - /// - public sealed class ProjectSample : RecordControl - { - /// - /// Create new instance. - /// - public ProjectSample() - : base(e => e.Id) - { - } - - /// - /// Project sample identifier. - /// - public int Id { get; set; } - - /// - /// Project identifier. - /// - public int Project { get; set; } - - /// - /// Status. - /// - public ProjectSampleStatus Status { get; set; } - - /// - /// Contact email. - /// - [EmailAddress] - public string Email { get; set; } - - /// - /// Note. - /// - public string Note { get; set; } - - /// - /// Address identifier. - /// - [Geocoder] - public string Address { get; set; } - - /// - /// Project object. - /// - public Project ProjectNavigation { get; set; } - - /// - /// Contact object. - /// - public Contact ContactNavigation { get; set; } - - /// - /// Address object. - /// - public Address AddressNavigation { get; set; } - } -} diff --git a/src/FunderMaps.Core/Entities/RecordControl.cs b/src/FunderMaps.Core/Entities/RecordControl.cs index a27d06386..3840ae14e 100644 --- a/src/FunderMaps.Core/Entities/RecordControl.cs +++ b/src/FunderMaps.Core/Entities/RecordControl.cs @@ -2,7 +2,7 @@ namespace FunderMaps.Core.Entities { - // TODO: Remove in the long term. This is meta data. + // FUTURE: Remove in the long term. This is meta data. /// /// Record timestamps. /// diff --git a/src/FunderMaps.Core/FunderMaps.Core.csproj b/src/FunderMaps.Core/FunderMaps.Core.csproj index 648993b88..d0e7b178e 100644 --- a/src/FunderMaps.Core/FunderMaps.Core.csproj +++ b/src/FunderMaps.Core/FunderMaps.Core.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/FunderMaps.Core/Interfaces/Repositories/ITestRepository.cs b/src/FunderMaps.Core/Interfaces/Repositories/ITestRepository.cs index e12242b07..50ac69318 100644 --- a/src/FunderMaps.Core/Interfaces/Repositories/ITestRepository.cs +++ b/src/FunderMaps.Core/Interfaces/Repositories/ITestRepository.cs @@ -10,6 +10,6 @@ public interface ITestRepository /// /// Check if backend is online. /// - Task IsAlive(); + Task IsAliveAsync(); } } diff --git a/src/FunderMaps.Core/Interfaces/Repositories/IUserRepository.cs b/src/FunderMaps.Core/Interfaces/Repositories/IUserRepository.cs index e72e3053b..b13c6d02b 100644 --- a/src/FunderMaps.Core/Interfaces/Repositories/IUserRepository.cs +++ b/src/FunderMaps.Core/Interfaces/Repositories/IUserRepository.cs @@ -23,13 +23,6 @@ public interface IUserRepository : IAsyncRepository /// Password hash as string. Task GetPasswordHashAsync(Guid id); - /// - /// Whether or not user is locked out. - /// - /// Entity identifier. - /// True if locked out, false otherwise. - Task IsLockedOutAsync(Guid id); - /// /// Update user password. /// diff --git a/src/FunderMaps.Core/Services/NullBlobStorageService.cs b/src/FunderMaps.Core/Services/NullBlobStorageService.cs index 299565447..167f33bf1 100644 --- a/src/FunderMaps.Core/Services/NullBlobStorageService.cs +++ b/src/FunderMaps.Core/Services/NullBlobStorageService.cs @@ -12,15 +12,6 @@ namespace FunderMaps.Core.Services /// internal class NullBlobStorageService : IBlobStorageService { - /// - /// Check if a file exist in storage. - /// - /// Storage container. - /// File name. - /// True if file exist, false otherwise. - public Task FileExistsAsync(string containerName, string fileName) - => Task.FromResult(false); - /// /// Retrieve file access link as uri. /// @@ -31,15 +22,6 @@ public Task FileExistsAsync(string containerName, string fileName) public Task GetAccessLinkAsync(string containerName, string fileName, double hoursValid) => Task.FromResult(new Uri("https://localhost/blob")); - /// - /// Store the file in the data store. - /// - /// Storage container. - /// File name. - /// Content stream. - public Task StoreFileAsync(string containerName, string fileName, Stream stream) - => Task.CompletedTask; - /// /// Stores a file in Amazon S3. /// diff --git a/src/FunderMaps.Core/Services/ProductService.cs b/src/FunderMaps.Core/Services/ProductService.cs index f02042522..9d0c407c6 100644 --- a/src/FunderMaps.Core/Services/ProductService.cs +++ b/src/FunderMaps.Core/Services/ProductService.cs @@ -59,6 +59,9 @@ private async Task GetStatisticsByExternalIdAsync(string id) MunicipalityReportCount = await _statisticsRepository.GetMunicipalityReportCountByExternalIdAsync(id), }; + /// + /// Generate drystand description text. + /// private string DescriptionDrystand(FoundationRisk? risk, double? drystand) => risk switch { @@ -79,6 +82,9 @@ var risk_low when ( _ => "Onbekend", }; + /// + /// Generate dewatering depth description text. + /// private string DescriptionDewateringDepth(FoundationRisk? risk, double? dewateringDepth, string soil) => risk switch { @@ -99,6 +105,9 @@ var risk_low when ( _ => "Onbekend", }; + /// + /// Generate bioinfection description text. + /// private string DescriptionBioInfection(FoundationRisk? risk) => risk switch { diff --git a/src/FunderMaps.Core/Types/AuditStatus.cs b/src/FunderMaps.Core/Types/AuditStatus.cs index b99a50775..c8c2c4aa5 100644 --- a/src/FunderMaps.Core/Types/AuditStatus.cs +++ b/src/FunderMaps.Core/Types/AuditStatus.cs @@ -20,7 +20,7 @@ public enum AuditStatus /// Done = 2, - // TODO: Remove. + // FUTURE: Remove. /// /// Discarded. /// diff --git a/src/FunderMaps.Core/Types/Bundle/BundleStatus.cs b/src/FunderMaps.Core/Types/Bundle/BundleStatus.cs deleted file mode 100644 index 5158bf1f0..000000000 --- a/src/FunderMaps.Core/Types/Bundle/BundleStatus.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace FunderMaps.Core.Types.MapLayer -{ - /// - /// Bundle status enum - /// - public enum BundleStatus - { - /// - /// This bundle has just been created. - /// - Created, - - /// - /// The bundle is being processed by some external entity. - /// The current version is still accurate. - /// - Processing, - - /// - /// The bundle is up to date and the current version is accurate. - /// - UpToDate, - - /// - /// The bundle has been deleted. - /// - Deleted, - } -} diff --git a/src/FunderMaps.Core/Types/Bundle/LayerColumnPair.cs b/src/FunderMaps.Core/Types/Bundle/LayerColumnPair.cs index db12a9e30..8fc839570 100644 --- a/src/FunderMaps.Core/Types/Bundle/LayerColumnPair.cs +++ b/src/FunderMaps.Core/Types/Bundle/LayerColumnPair.cs @@ -15,8 +15,6 @@ public sealed class LayerColumnPair [Required] public Guid LayerId { get; set; } - // TODO Min length attribute? - // TODO Must contain geom attribute? /// /// Collection of selected column names. /// diff --git a/src/FunderMaps.Core/Types/ProjectSampleStatus.cs b/src/FunderMaps.Core/Types/ProjectSampleStatus.cs deleted file mode 100644 index b4e089201..000000000 --- a/src/FunderMaps.Core/Types/ProjectSampleStatus.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace FunderMaps.Core.Types -{ - /// - /// Project sample status. - /// - public enum ProjectSampleStatus - { - /// - /// Contacted. - /// - Contacted = 0, - - /// - /// Quotation reserach. - /// - QuotationReserach = 1, - - /// - /// Research in progress. - /// - ResearchInProgress = 2, - - /// - /// Research pending. - /// - ResearchPending = 3, - - /// - /// Research canceled. - /// - ResearchCanceled = 4, - - /// - /// Quotation recovery. - /// - QuotationRecovery = 5, - - /// - /// Waiting on permit. - /// - WaitingOnPermit = 6, - - /// - /// Recovery in progress. - /// - RecoveryInProgress = 7, - - /// - /// Recovery pending. - /// - RecoveryPending = 8, - - /// - /// Recovery canceled. - /// - RecoveryCanceled = 9, - - /// - /// None. - /// - None = 10, - } -} diff --git a/src/FunderMaps.Data/FunderMaps.Data.csproj b/src/FunderMaps.Data/FunderMaps.Data.csproj index 6dd0bcc9f..496b0bda1 100644 --- a/src/FunderMaps.Data/FunderMaps.Data.csproj +++ b/src/FunderMaps.Data/FunderMaps.Data.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/FunderMaps.Data/Providers/NpgsqlDbProvider.cs b/src/FunderMaps.Data/Providers/NpgsqlDbProvider.cs index 91d5c8947..6d1c78f50 100644 --- a/src/FunderMaps.Data/Providers/NpgsqlDbProvider.cs +++ b/src/FunderMaps.Data/Providers/NpgsqlDbProvider.cs @@ -50,7 +50,6 @@ static NpgsqlDbProvider() NpgsqlConnection.GlobalTypeMapper.MapEnum("report.audit_status"); NpgsqlConnection.GlobalTypeMapper.MapEnum("geocoder.building_type"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.built_year_source"); - NpgsqlConnection.GlobalTypeMapper.MapEnum("maplayer.bundle_status"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.construction_pile"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.crack_type"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.enforcement_term"); @@ -66,7 +65,6 @@ static NpgsqlDbProvider() NpgsqlConnection.GlobalTypeMapper.MapEnum("report.inquiry_type"); NpgsqlConnection.GlobalTypeMapper.MapEnum("application.organization_role"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.pile_type"); - NpgsqlConnection.GlobalTypeMapper.MapEnum("report.project_sample_status"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.quality"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.recovery_document_type"); NpgsqlConnection.GlobalTypeMapper.MapEnum("report.recovery_status"); diff --git a/src/FunderMaps.Data/Repositories/IncidentRepository.cs b/src/FunderMaps.Data/Repositories/IncidentRepository.cs index 308b8c0df..6828b7050 100644 --- a/src/FunderMaps.Data/Repositories/IncidentRepository.cs +++ b/src/FunderMaps.Data/Repositories/IncidentRepository.cs @@ -135,26 +135,26 @@ public static void MapToWriter(DbContext context, Incident entity) public static Incident MapFromReader(DbDataReader reader, int offset = 0) => new() { - Id = reader.GetSafeString(offset + 0), - FoundationType = reader.GetFieldValue(offset + 1), - ChainedBuilding = reader.GetBoolean(offset + 2), - Owner = reader.GetBoolean(offset + 3), - FoundationRecovery = reader.GetBoolean(offset + 4), - NeighborRecovery = reader.GetBoolean(offset + 5), - FoundationDamageCause = reader.GetFieldValue(offset + 6), - DocumentFile = reader.GetSafeFieldValue(offset + 7), - Note = reader.GetSafeString(offset + 8), - InternalNote = reader.GetSafeString(offset + 9), - Email = reader.GetSafeString(offset + 10), - CreateDate = reader.GetDateTime(offset + 11), - UpdateDate = reader.GetSafeDateTime(offset + 12), - DeleteDate = reader.GetSafeDateTime(offset + 13), - FoundationDamageCharacteristics = reader.GetSafeFieldValue(offset + 14), - EnvironmentDamageCharacteristics = reader.GetSafeFieldValue(offset + 15), - Address = reader.GetSafeString(offset + 16), - AuditStatus = reader.GetFieldValue(offset + 17), - QuestionType = reader.GetFieldValue(offset + 18), - Meta = reader.GetFieldValue(offset + 19), + Id = reader.GetSafeString(offset++), + FoundationType = reader.GetFieldValue(offset++), + ChainedBuilding = reader.GetBoolean(offset++), + Owner = reader.GetBoolean(offset++), + FoundationRecovery = reader.GetBoolean(offset++), + NeighborRecovery = reader.GetBoolean(offset++), + FoundationDamageCause = reader.GetFieldValue(offset++), + DocumentFile = reader.GetSafeFieldValue(offset++), + Note = reader.GetSafeString(offset++), + InternalNote = reader.GetSafeString(offset++), + Email = reader.GetSafeString(offset++), + CreateDate = reader.GetDateTime(offset++), + UpdateDate = reader.GetSafeDateTime(offset++), + DeleteDate = reader.GetSafeDateTime(offset++), + FoundationDamageCharacteristics = reader.GetSafeFieldValue(offset++), + EnvironmentDamageCharacteristics = reader.GetSafeFieldValue(offset++), + Address = reader.GetSafeString(offset++), + AuditStatus = reader.GetFieldValue(offset++), + QuestionType = reader.GetFieldValue(offset++), + Meta = reader.GetFieldValue(offset++), }; /// diff --git a/src/FunderMaps.Data/Repositories/OrganizationProposalRepository.cs b/src/FunderMaps.Data/Repositories/OrganizationProposalRepository.cs index 0e98c7e10..ea5a73c0b 100644 --- a/src/FunderMaps.Data/Repositories/OrganizationProposalRepository.cs +++ b/src/FunderMaps.Data/Repositories/OrganizationProposalRepository.cs @@ -50,7 +50,7 @@ public override async Task CountAsync() { var sql = @" SELECT COUNT(*) - FROM application.create_organization_proposal"; + FROM application.organization_proposal"; await using var context = await DbContextFactory.CreateAsync(sql); diff --git a/src/FunderMaps.Data/Repositories/OrganizationUserRepository.cs b/src/FunderMaps.Data/Repositories/OrganizationUserRepository.cs index b73d38798..680042e45 100644 --- a/src/FunderMaps.Data/Repositories/OrganizationUserRepository.cs +++ b/src/FunderMaps.Data/Repositories/OrganizationUserRepository.cs @@ -46,7 +46,8 @@ SELECT user_id FROM application.organization_user WHERE organization_id = @organization_id"; - // ConstructNavigation(ref sql, navigation); // TODO: + // TODO: + // sql = ConstructNavigation(sql, navigation); await using var context = await DbContextFactory.CreateAsync(sql); @@ -66,7 +67,8 @@ FROM application.organization_user WHERE organization_id = @organization_id AND role = ANY(@role)"; - // ConstructNavigation(ref sql, navigation); // TODO: + // TODO: + // sql = ConstructNavigation(sql, navigation); await using var context = await DbContextFactory.CreateAsync(sql); diff --git a/src/FunderMaps.Data/Repositories/RecoverySampleRepository.cs b/src/FunderMaps.Data/Repositories/RecoverySampleRepository.cs index 91d3f1ef2..187b6484c 100644 --- a/src/FunderMaps.Data/Repositories/RecoverySampleRepository.cs +++ b/src/FunderMaps.Data/Repositories/RecoverySampleRepository.cs @@ -188,7 +188,6 @@ FROM report.recovery_sample AS s return MapFromReader(reader); } - // TODO: Filter per tenant? /// /// Retrieve all . /// @@ -213,12 +212,17 @@ public override async IAsyncEnumerable ListAllAsync(Navigation n s.permit_date, s.recovery_date FROM report.recovery_sample AS s + JOIN report.recovery AS r ON r.id = s.recovery + JOIN application.attribution AS a ON a.id = r.attribution + WHERE a.owner = @tenant ORDER BY s.create_date DESC"; sql = ConstructNavigation(sql, navigation); await using var context = await DbContextFactory.CreateAsync(sql); + context.AddParameterWithValue("tenant", AppContext.TenantId); + await foreach (var reader in context.EnumerableReaderAsync()) { yield return MapFromReader(reader); diff --git a/src/FunderMaps.Data/Repositories/TestRepository.cs b/src/FunderMaps.Data/Repositories/TestRepository.cs index 753150068..a4aa514f5 100644 --- a/src/FunderMaps.Data/Repositories/TestRepository.cs +++ b/src/FunderMaps.Data/Repositories/TestRepository.cs @@ -16,7 +16,7 @@ internal sealed class TestRepository : DbServiceBase, ITestRepository /// Explicit check on result, not all commands are submitted /// to the database. /// - public async Task IsAlive() // TODO: Rename to IsAliveAsync + public async Task IsAliveAsync() { var sql = @"SELECT 1"; diff --git a/src/FunderMaps.Data/Repositories/UserRepository.cs b/src/FunderMaps.Data/Repositories/UserRepository.cs index 626c0c79d..1732e3f82 100644 --- a/src/FunderMaps.Data/Repositories/UserRepository.cs +++ b/src/FunderMaps.Data/Repositories/UserRepository.cs @@ -204,23 +204,6 @@ FROM application.user return reader.GetSafeString(0); } - /// - /// Whether or not user is locked out. - /// - /// Entity identifier. - /// True if locked out, false otherwise. - public async Task IsLockedOutAsync(Guid id) - { - var sql = @" - SELECT application.is_locked_out(@id)"; - - await using var context = await DbContextFactory.CreateAsync(sql); - - context.AddParameterWithValue("id", id); - - return await context.ScalarAsync(); - } - /// /// Retrieve all . /// diff --git a/src/FunderMaps.Infrastructure/Email/SmtpService.cs b/src/FunderMaps.Infrastructure/Email/SmtpService.cs index 7bea307f6..ee35c870a 100644 --- a/src/FunderMaps.Infrastructure/Email/SmtpService.cs +++ b/src/FunderMaps.Infrastructure/Email/SmtpService.cs @@ -15,7 +15,6 @@ namespace FunderMaps.Infrastructure.Email { // FUTURE: Catch ex. // FUTURE: We can configure much more and we will in a next release. - // TODO: Check input. /// /// Send email to the MTA. /// diff --git a/src/FunderMaps.Infrastructure/FunderMaps.Infrastructure.csproj b/src/FunderMaps.Infrastructure/FunderMaps.Infrastructure.csproj index bd492273a..c551c6e69 100644 --- a/src/FunderMaps.Infrastructure/FunderMaps.Infrastructure.csproj +++ b/src/FunderMaps.Infrastructure/FunderMaps.Infrastructure.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/FunderMaps.Infrastructure/Storage/SpacesBlobStorageService.cs b/src/FunderMaps.Infrastructure/Storage/SpacesBlobStorageService.cs index 810bbdc8f..fb2187345 100644 --- a/src/FunderMaps.Infrastructure/Storage/SpacesBlobStorageService.cs +++ b/src/FunderMaps.Infrastructure/Storage/SpacesBlobStorageService.cs @@ -162,7 +162,7 @@ public async Task StoreDirectoryAsync(string directoryName, string directoryPath } /// - /// Removes a directory. + /// Remove directory and its contents. /// /// Full path of the directory to delete. /// See . diff --git a/src/FunderMaps.Portal/Controllers/IncidentPortalController.cs b/src/FunderMaps.Portal/Controllers/IncidentPortalController.cs index 8677c970d..f4812f59b 100644 --- a/src/FunderMaps.Portal/Controllers/IncidentPortalController.cs +++ b/src/FunderMaps.Portal/Controllers/IncidentPortalController.cs @@ -17,7 +17,7 @@ #pragma warning disable CA1062 // Validate arguments of public methods namespace FunderMaps.Portal.Controllers { - // TODO: Rename and refactor controller + // FUTURE: Split the logic into two separate controllers. /// /// Endpoint controller for incident operations. /// diff --git a/src/FunderMaps.WebApi/Controllers/Application/OrganizationSetupController.cs b/src/FunderMaps.WebApi/Controllers/Application/OrganizationSetupController.cs index 52ea953a1..5fea014e8 100644 --- a/src/FunderMaps.WebApi/Controllers/Application/OrganizationSetupController.cs +++ b/src/FunderMaps.WebApi/Controllers/Application/OrganizationSetupController.cs @@ -1,5 +1,4 @@ -using AutoMapper; -using FunderMaps.Core.Entities; +using FunderMaps.Core.Entities; using FunderMaps.Core.Interfaces; using FunderMaps.Core.Interfaces.Repositories; using FunderMaps.WebApi.DataTransferObjects; @@ -21,16 +20,14 @@ namespace FunderMaps.WebApi.Controllers.Application [AllowAnonymous] public class OrganizationSetupController : ControllerBase { - private readonly IMapper _mapper; private readonly IOrganizationRepository _organizationRepository; private readonly IPasswordHasher _passwordHasher; /// /// Create new instance. /// - public OrganizationSetupController(IMapper mapper, IOrganizationRepository organizationRepository, IPasswordHasher passwordHasher) + public OrganizationSetupController(IOrganizationRepository organizationRepository, IPasswordHasher passwordHasher) { - _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _organizationRepository = organizationRepository ?? throw new ArgumentNullException(nameof(organizationRepository)); _passwordHasher = passwordHasher ?? throw new ArgumentNullException(nameof(passwordHasher)); } diff --git a/src/FunderMaps.WebApi/Controllers/Application/ProposalController.cs b/src/FunderMaps.WebApi/Controllers/Application/ProposalController.cs index ea11add79..6a0159110 100644 --- a/src/FunderMaps.WebApi/Controllers/Application/ProposalController.cs +++ b/src/FunderMaps.WebApi/Controllers/Application/ProposalController.cs @@ -31,7 +31,7 @@ public ProposalController(IMapper mapper, IOrganizationProposalRepository organi _organizationProposalRepository = organizationProposalRepository ?? throw new ArgumentNullException(nameof(organizationProposalRepository)); } - // GET: api/organization/stats + // GET: api/organization/proposal/stats /// /// Return organization proposal statistics. /// diff --git a/src/FunderMaps.WebApi/Controllers/Report/IncidentController.cs b/src/FunderMaps.WebApi/Controllers/Report/IncidentController.cs index b1b756ce5..560423d57 100644 --- a/src/FunderMaps.WebApi/Controllers/Report/IncidentController.cs +++ b/src/FunderMaps.WebApi/Controllers/Report/IncidentController.cs @@ -110,18 +110,23 @@ await _blobStorageService.StoreFileAsync( return Ok(output); } - // GET: api/inquiry/download + // GET: api/incident/{id}/download /// /// Retrieve document access link. /// - [HttpGet("{id:int}/download")] + [HttpGet("{id}/download")] public async Task GetDocumentAccessLinkAsync([Incident] string id) { // Act. Incident incident = await _incidentRepository.GetByIdAsync(id); + if (incident.DocumentFile is null) + { + return NoContent(); + } + Uri link = await _blobStorageService.GetAccessLinkAsync( containerName: Core.Constants.IncidentStorageFolderName, - fileName: incident.DocumentFile[0], // TODO + fileName: incident.DocumentFile[0], // FUTURE: Return all documents or select per index. hoursValid: 1); // Map. diff --git a/src/FunderMaps.WebApi/DataTransferObjects/RecoveryDto.cs b/src/FunderMaps.WebApi/DataTransferObjects/RecoveryDto.cs index 1f1c8ac35..0b69ca191 100644 --- a/src/FunderMaps.WebApi/DataTransferObjects/RecoveryDto.cs +++ b/src/FunderMaps.WebApi/DataTransferObjects/RecoveryDto.cs @@ -4,7 +4,6 @@ namespace FunderMaps.WebApi.DataTransferObjects { - // TODO: Missing AuditStatus? /// /// Recovery DTO. /// diff --git a/src/FunderMaps.WebApi/MapperProfile.cs b/src/FunderMaps.WebApi/MapperProfile.cs index 6beeda0ca..d57e649d1 100644 --- a/src/FunderMaps.WebApi/MapperProfile.cs +++ b/src/FunderMaps.WebApi/MapperProfile.cs @@ -17,7 +17,7 @@ public MapperProfile() CreateMap(); CreateMap(); CreateMap().ReverseMap(); - // TODO: Try and map nested objects in a cleaner way + // FUTURE: Try and map nested objects in a cleaner way CreateMap() .ForMember(dest => dest.AuditStatus, o => o.MapFrom(src => src.State.AuditStatus)) .ForMember(dest => dest.Reviewer, o => o.MapFrom(src => src.Attribution.Reviewer)) @@ -32,7 +32,7 @@ public MapperProfile() CreateMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); - // TODO: Try and map nested objects in a cleaner way + // FUTURE: Try and map nested objects in a cleaner way CreateMap() .ForMember(dest => dest.AuditStatus, o => o.MapFrom(src => src.State.AuditStatus)) .ForMember(dest => dest.Reviewer, o => o.MapFrom(src => src.Attribution.Reviewer)) diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/ApplicationStub.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/ApplicationStub.cs index ecddaa872..7888afacf 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/ApplicationStub.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/ApplicationStub.cs @@ -88,9 +88,11 @@ public static async Task CreateOrganizationUserAsyn Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(newObject.GivenName, returnObject.GivenName); Assert.Equal(newObject.LastName, returnObject.LastName); + Assert.Equal(newObject.Email, returnObject.Email); Assert.Equal(newObject.Avatar, returnObject.Avatar); - - // FUTURE: Add more checks. + Assert.Equal(newObject.JobTitle, returnObject.JobTitle); + Assert.Equal(newObject.PhoneNumber, returnObject.PhoneNumber); + Assert.Equal(newObject.Role, returnObject.Role); return newObject with { diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/ContractorTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/ContractorTests.cs index e474847df..b0b1cf6f7 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/ContractorTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/ContractorTests.cs @@ -35,6 +35,7 @@ public async Task GetAllContractorReturnAllContractor(OrganizationRole role) // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.True(returnList.Count >= 1); + Assert.True(response.Headers.CacheControl.Public); } } } diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationAdminTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationAdminTests.cs index 4a06ecd06..d90df463f 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationAdminTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationAdminTests.cs @@ -25,6 +25,19 @@ public async Task OrganizationLifeCycle() var organizationSetup = await ApplicationStub.CreateOrganizationAsync(Factory, organizationProposal); var organization = await ApplicationStub.GetOrganizationAsync(Factory, organizationProposal); + { + // Arrange + using var client = Factory.CreateAdminClient(); + + // Act + var response = await client.GetAsync("api/admin/organization/stats"); + var returnList = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(returnList.Count >= 1); + } + { // Arrange using var client = Factory.CreateAdminClient(); @@ -38,6 +51,21 @@ public async Task OrganizationLifeCycle() Assert.True(returnList.Count >= 1); } + { + // Arrange + using var client = Factory.CreateAdminClient(); + + // Act + var response = await client.GetAsync($"api/admin/organization/{organization.Id}"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal(organization.Id, returnObject.Id); + Assert.NotNull(organization.Name); + Assert.NotNull(organization.Email); + } + { // Arrange using var client = Factory.CreateAdminClient(); diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationProposalTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationProposalTests.cs index 022422827..d3ff2bea8 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationProposalTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationProposalTests.cs @@ -1,4 +1,5 @@ -using FunderMaps.IntegrationTests.Faker; +using FunderMaps.AspNetCore.DataTransferObjects; +using FunderMaps.IntegrationTests.Faker; using FunderMaps.WebApi.DataTransferObjects; using System.Collections.Generic; using System.Net; @@ -23,6 +24,19 @@ public async Task OrganizationProposalLifeCycle() { var organizationProposal = await ApplicationStub.CreateProposalAsync(Factory); + { + // Arrange + using var client = Factory.CreateAdminClient(); + + // Act + var response = await client.GetAsync("api/organization/proposal/stats"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(returnObject.Count >= 1); + } + { // Arrange using var client = Factory.CreateAdminClient(); @@ -33,6 +47,7 @@ public async Task OrganizationProposalLifeCycle() // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal(organizationProposal.Id, returnObject.Id); } { diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationTests.cs index 4088e109b..e2f06ea73 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationTests.cs @@ -36,6 +36,8 @@ public async Task GetOrganizationFromSessionReturnSingleOrganization(Organizatio // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(Guid.Parse("05203318-6c55-43c1-a6a6-bb8c83f930c3"), returnObject.Id); + Assert.NotNull(returnObject.Name); + Assert.NotNull(returnObject.Email); } [Fact] diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationUserTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationUserTests.cs index 9247a5804..bd4372918 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationUserTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/OrganizationUserTests.cs @@ -47,7 +47,7 @@ public async Task GetAllOrganizationUserFromSessionReturnAllOrganizationUser() // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.True(returnList.Count > 0); // TODO: update + Assert.True(returnList.Count >= 1); } [Fact] diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/ReviewerTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/ReviewerTests.cs index 0ea52c38d..25383b3e1 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/ReviewerTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/ReviewerTests.cs @@ -33,7 +33,8 @@ public async Task GetAllReviewerReturnAllReviewer(OrganizationRole role) // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.True(returnList.Count > 0); + Assert.True(returnList.Count >= 1); + Assert.True(response.Headers.CacheControl.Private); } [Fact] diff --git a/tests/FunderMaps.IntegrationTests/Backend/Application/UserTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Application/UserTests.cs index 8d7ca7941..d279fa0f7 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Application/UserTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Application/UserTests.cs @@ -22,7 +22,7 @@ public UserTests(BackendFixtureFactory factory) public async Task GetUserFromSessionReturnSingleUser() { // Arrange - using var client = Factory.CreateClient(); + using var client = Factory.CreateAlterClient(); // Act var response = await client.GetAsync("api/user"); @@ -30,16 +30,16 @@ public async Task GetUserFromSessionReturnSingleUser() // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal(Guid.Parse("1a93cfb3-f097-4697-a998-71cdd9cfaead"), returnObject.Id); - Assert.Equal("lester@contoso.com", returnObject.Email); + Assert.Equal(Guid.Parse("ab403d16-e428-4a75-9eec-3dd08b294988"), returnObject.Id); + Assert.Equal("corene@contoso.com", returnObject.Email); } [Fact] public async Task UpdateUserFromSessionReturnNoContent() { // Arrange - using var client = Factory.CreateClient(); - var updateObject = new UserFaker().Generate(); + using var client = Factory.CreateAlterClient(); + var updateObject = new UserDtoFaker().Generate(); // Act var response = await client.PutAsJsonAsync("api/user", updateObject); @@ -54,5 +54,34 @@ public async Task UpdateUserFromSessionReturnNoContent() Assert.Equal(updateObject.JobTitle, returnObject.JobTitle); Assert.Equal(updateObject.PhoneNumber, returnObject.PhoneNumber); } + + [Fact] + public async Task ChangePasswordFromSessionReturnNoContent() + { + // Arrange + using var client = Factory.CreateAlterClient(); + var newObject = new ChangePasswordDtoFaker() + .RuleFor(f => f.OldPassword, f => "fundermaps") + .Generate(); + + // Act + var response = await client.PostAsJsonAsync("user/change-password", newObject); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + + await TestStub.LoginAsync(Factory, "corene@contoso.com", newObject.NewPassword); + + response = await client.PostAsJsonAsync("user/change-password", new ChangePasswordDto() + { + OldPassword = newObject.NewPassword, + NewPassword = "fundermaps", + }); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + + await TestStub.LoginAsync(Factory, "corene@contoso.com", "fundermaps"); + } } } diff --git a/tests/FunderMaps.IntegrationTests/Backend/Geocoder/AddressTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Geocoder/AddressTests.cs index 1987dafcf..062e28280 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Geocoder/AddressTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Geocoder/AddressTests.cs @@ -35,6 +35,7 @@ public async Task GetAddressByIdReturnSingleAddress() Assert.Equal("2612PA", returnObject.PostalCode); Assert.Equal("Poortweg", returnObject.Street); Assert.Equal("Delft", returnObject.City); + Assert.True(response.Headers.CacheControl.Public); } [Theory] @@ -53,13 +54,13 @@ public async Task GetAddressByGeoIdReturnSingleAddress(string address, string ex // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(expected, returnObject.Id); + Assert.True(response.Headers.CacheControl.Public); } [Theory] [InlineData(OrganizationRole.Superuser)] [InlineData(OrganizationRole.Verifier)] [InlineData(OrganizationRole.Writer)] - [InlineData(OrganizationRole.Reader)] public async Task GetAddressByIdReturnOk(OrganizationRole role) { // Arrange @@ -70,6 +71,7 @@ public async Task GetAddressByIdReturnOk(OrganizationRole role) // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(response.Headers.CacheControl.Public); } } } diff --git a/tests/FunderMaps.IntegrationTests/Backend/Maplayer/BundleTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Maplayer/BundleTests.cs new file mode 100644 index 000000000..2db5a95ab --- /dev/null +++ b/tests/FunderMaps.IntegrationTests/Backend/Maplayer/BundleTests.cs @@ -0,0 +1,36 @@ +using FunderMaps.WebApi.DataTransferObjects; +using System.Collections.Generic; +using System.Net; +using System.Net.Http.Json; +using System.Threading.Tasks; +using Xunit; + +namespace FunderMaps.IntegrationTests.Backend.Maplayer +{ + public class BundleTests : IClassFixture + { + private BackendFixtureFactory Factory { get; } + + /// + /// Create new instance. + /// + public BundleTests(BackendFixtureFactory factory) + => Factory = factory; + + [Fact] + public async Task GetAllBundleReturnGetAllBundle() + { + // Arrange + using var client = Factory.CreateClient(); + + // Act + var response = await client.GetAsync($"api/bundle"); + var returnObject = await response.Content.ReadFromJsonAsync>(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(returnObject.Count >= 1); + Assert.True(response.Headers.CacheControl.Private); + } + } +} diff --git a/tests/FunderMaps.IntegrationTests/Backend/Maplayer/LayerTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Maplayer/LayerTests.cs index 1bde4462d..daca4811d 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Maplayer/LayerTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Maplayer/LayerTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Xunit; -namespace FunderMaps.IntegrationTests.Backend.Geocoder +namespace FunderMaps.IntegrationTests.Backend.Maplayer { public class LayerTests : IClassFixture { @@ -30,6 +30,7 @@ public async Task GetLayerByIdReturnOk() // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("Funderingsrisico", returnObject.Name); + Assert.True(response.Headers.CacheControl.Public); } [Fact] @@ -45,6 +46,7 @@ public async Task GetAllLayerReturnGetAllLayer() // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.True(returnObject.Count >= 10); + Assert.True(response.Headers.CacheControl.Public); } } } diff --git a/tests/FunderMaps.IntegrationTests/Backend/Report/IncidentTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Report/IncidentTests.cs index dc286597f..e7c4b4d2c 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Report/IncidentTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Report/IncidentTests.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Xunit; using FunderMaps.IntegrationTests.Faker; +using System.Net.Http; +using System.Collections.Generic; namespace FunderMaps.IntegrationTests.Backend.Report { @@ -36,76 +38,145 @@ public async Task UploadDocumentReturnDocument() } [Fact] - public async Task CreateIncidentReturnIncident() + public async Task UploadEmptyFormReturnBadRequest() { // Arrange - var incident = new IncidentDtoFaker() - .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") - .Generate(); - using var client = Factory.CreateClient(); + using var formContent = new MultipartFormDataContent(); + using var client = Factory.CreateClient(OrganizationRole.Writer); // Act - var response = await client.PostAsJsonAsync("api/incident", incident); - var returnObject = await response.Content.ReadFromJsonAsync(); + var response = await client.PostAsync("api/incident/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); // Assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.StartsWith("FIR", returnObject.Id, StringComparison.InvariantCulture); - Assert.Equal(AuditStatus.Todo, returnObject.AuditStatus); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); } [Fact] - public async Task GetIncidentByIdReturnSingleIncident() + public async Task UploadEmptyDocumentReturnBadRequest() { // Arrange - var incident = new IncidentDtoFaker() - .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") - .Generate(); - using var client = Factory.CreateClient(); - incident = await client.PostAsJsonGetFromJsonAsync("api/incident", incident); + using var formContent = new FileUploadContent( + mediaType: "application/pdf", + fileExtension: "pdf", + byteContentLength: 0); + using var client = Factory.CreateClient(OrganizationRole.Writer); // Act - var response = await client.GetAsync($"api/incident/{incident.Id}"); - var returnObject = await response.Content.ReadFromJsonAsync(); + var response = await client.PostAsync("api/incident/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); // Assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.StartsWith("FIR", returnObject.Id, StringComparison.InvariantCulture); - Assert.Equal(AuditStatus.Todo, returnObject.AuditStatus); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); } [Fact] - public async Task UpdateIncidentReturnNoContent() + public async Task UploadForbiddenDocumentReturnBadRequest() { // Arrange - var incident = new IncidentDtoFaker() - .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") - .Generate(); - using var client = Factory.CreateClient(); - incident = await client.PostAsJsonGetFromJsonAsync("api/incident", incident); + using var formContent = new FileUploadContent( + mediaType: "font/woff", + fileExtension: "woff"); + using var client = Factory.CreateClient(OrganizationRole.Writer); // Act - var response = await client.PutAsJsonAsync($"api/incident/{incident.Id}", new IncidentDtoFaker().Generate()); + var response = await client.PostAsync("api/incident/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); // Assert - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); } [Fact] - public async Task DeleteIncidentReturnNoContent() + public async Task IncidentLifeCycle() { - // Arrange - var incident = new IncidentDtoFaker() - .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") - .Generate(); - using var client = Factory.CreateClient(); - incident = await client.PostAsJsonGetFromJsonAsync("api/incident", incident); - - // Act - var response = await client.DeleteAsync($"api/incident/{incident.Id}"); - - // Assert - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + var incident = await ReportStub.CreateIncidentAsync(Factory); + + { + // Arrange + using var client = Factory.CreateClient(); + + if (incident.DocumentFile.Length > 0) + { + // Act + var response = await client.GetAsync($"api/incident/{incident.Id}/download"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("https", returnObject.AccessLink.Scheme); + } + else + { + // Act + var response = await client.GetAsync($"api/incident/{incident.Id}/download"); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + } + } + + { + // Arrange + using var client = Factory.CreateClient(); + + // Act + var response = await client.GetAsync($"api/incident/stats"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(returnObject.Count >= 1); + } + + { + // Arrange + using var client = Factory.CreateClient(); + + // Act + var response = await client.GetAsync($"api/incident/{incident.Id}"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.StartsWith("FIR", returnObject.Id, StringComparison.InvariantCulture); + Assert.Equal(AuditStatus.Todo, returnObject.AuditStatus); + } + + { + // Arrange + using var client = Factory.CreateClient(); + + // Act + var response = await client.GetAsync($"api/incident"); + var returnList = await response.Content.ReadFromJsonAsync>(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(returnList.Count >= 1); + } + + { + // Arrange + using var client = Factory.CreateClient(OrganizationRole.Writer); + var newObject = new IncidentDtoFaker() + .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") + .Generate(); + + // Act + var response = await client.PutAsJsonAsync($"api/incident/{incident.Id}", newObject); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + } + + await ReportStub.DeleteIncidentAsync(Factory, incident); } } } diff --git a/tests/FunderMaps.IntegrationTests/Backend/Report/InquiryTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Report/InquiryTests.cs index 8e7c2a9f2..d95bf7e06 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Report/InquiryTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Report/InquiryTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using System.Net.Http.Json; using System.Threading.Tasks; using Xunit; @@ -51,11 +52,80 @@ public async Task UploadDocumentReturnForbidden() Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); } + [Fact] + public async Task UploadEmptyFormReturnBadRequest() + { + // Arrange + using var formContent = new MultipartFormDataContent(); + using var client = Factory.CreateClient(OrganizationRole.Writer); + + // Act + var response = await client.PostAsync("api/inquiry/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public async Task UploadEmptyDocumentReturnBadRequest() + { + // Arrange + using var formContent = new FileUploadContent( + mediaType: "application/pdf", + fileExtension: "pdf", + byteContentLength: 0); + using var client = Factory.CreateClient(OrganizationRole.Writer); + + // Act + var response = await client.PostAsync("api/inquiry/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public async Task UploadForbiddenDocumentReturnBadRequest() + { + // Arrange + using var formContent = new FileUploadContent( + mediaType: "font/woff", + fileExtension: "woff"); + using var client = Factory.CreateClient(OrganizationRole.Writer); + + // Act + var response = await client.PostAsync("api/inquiry/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + [Fact] public async Task InquiryLifeCycle() { var inquiry = await ReportStub.CreateInquiryAsync(Factory); + { + // Arrange + using var client = Factory.CreateClient(); + + // Act + var response = await client.GetAsync($"api/inquiry/{inquiry.Id}/download"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("https", returnObject.AccessLink.Scheme); + } + { // Arrange using var client = Factory.CreateClient(); diff --git a/tests/FunderMaps.IntegrationTests/Backend/Report/RecoveryTests.cs b/tests/FunderMaps.IntegrationTests/Backend/Report/RecoveryTests.cs index 4100b88e9..240aaf4c5 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Report/RecoveryTests.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Report/RecoveryTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using System.Net.Http.Json; using System.Threading.Tasks; using Xunit; @@ -51,11 +52,81 @@ public async Task UploadDocumentReturnForbidden() Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); } + [Fact] + public async Task UploadEmptyFormReturnBadRequest() + { + // Arrange + using var formContent = new MultipartFormDataContent(); + using var client = Factory.CreateClient(OrganizationRole.Writer); + + // Act + var response = await client.PostAsync("api/recovery/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public async Task UploadEmptyDocumentReturnBadRequest() + { + // Arrange + using var formContent = new FileUploadContent( + mediaType: "application/pdf", + fileExtension: "pdf", + byteContentLength: 0); + using var client = Factory.CreateClient(OrganizationRole.Writer); + + // Act + var response = await client.PostAsync("api/recovery/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public async Task UploadForbiddenDocumentReturnBadRequest() + { + // Arrange + using var formContent = new FileUploadContent( + mediaType: "font/woff", + fileExtension: "woff"); + using var client = Factory.CreateClient(OrganizationRole.Writer); + + // Act + var response = await client.PostAsync("api/recovery/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] public async Task RecoveryLifeCycle() { var recovery = await ReportStub.CreateRecoveryAsync(Factory); + { + // Arrange + using var client = Factory.CreateClient(); + + // Act + var response = await client.GetAsync($"api/recovery/{recovery.Id}/download"); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("https", returnObject.AccessLink.Scheme); + } + { // Arrange using var client = Factory.CreateClient(); diff --git a/tests/FunderMaps.IntegrationTests/Backend/Report/ReportStub.cs b/tests/FunderMaps.IntegrationTests/Backend/Report/ReportStub.cs index 4e07db37b..1d1462854 100644 --- a/tests/FunderMaps.IntegrationTests/Backend/Report/ReportStub.cs +++ b/tests/FunderMaps.IntegrationTests/Backend/Report/ReportStub.cs @@ -2,6 +2,7 @@ using System.Net; using System.Net.Http.Json; using System.Threading.Tasks; +using FunderMaps.AspNetCore.DataTransferObjects; using FunderMaps.Core.Types; using FunderMaps.IntegrationTests.Faker; using FunderMaps.WebApi.DataTransferObjects; @@ -56,6 +57,26 @@ public static async Task CreateInquiryAsync(BackendFixtureFactory fa return returnObject; } + public static async Task CreateIncidentAsync(BackendFixtureFactory factory) + { + // Arrange + var incident = new IncidentDtoFaker() + .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") + .Generate(); + using var client = factory.CreateClient(); + + // Act + var response = await client.PostAsJsonAsync("api/incident", incident); + var returnObject = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.StartsWith("FIR", returnObject.Id, StringComparison.InvariantCulture); + Assert.Equal(AuditStatus.Todo, returnObject.AuditStatus); + + return returnObject; + } + public static async Task DeleteRecoveryAsync(BackendFixtureFactory factory, RecoveryDto recovery) { // Arrange @@ -80,6 +101,18 @@ public static async Task DeleteInquiryAsync(BackendFixtureFactory factory, Inqui Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } + public static async Task DeleteIncidentAsync(BackendFixtureFactory factory, IncidentDto incident) + { + // Arrange + using var client = factory.CreateClient(); + + // Act + var response = await client.DeleteAsync($"api/incident/{incident.Id}"); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + } + public static async Task CreateRecoverySampleAsync(BackendFixtureFactory factory, RecoveryDto recovery) { // Arrange diff --git a/tests/FunderMaps.IntegrationTests/Extensions/BogusDataSetsExtensions.cs b/tests/FunderMaps.IntegrationTests/Extensions/BogusDataSetsExtensions.cs index 2cfa7b5c2..eb79361ca 100644 --- a/tests/FunderMaps.IntegrationTests/Extensions/BogusDataSetsExtensions.cs +++ b/tests/FunderMaps.IntegrationTests/Extensions/BogusDataSetsExtensions.cs @@ -1,29 +1,7 @@ -// using Bogus; -// using Bogus.DataSets; - namespace Bogus.DataSets { public static class BogusDataSetsExtensions { - // FUTURE: Secure path may not be necessary anymore - public static string RemoteFileWithSecureUrl(this Internet internet, string[] providedFileExt = null) - { - var fileExt = new string[] - { - ".pdf", - ".png", - ".gif", - ".txt", - }; - - if (providedFileExt is not null) - { - fileExt = providedFileExt; - } - - return internet.UrlWithPath("https", internet.DomainName(), internet.Random.ArrayElement(fileExt)); - } - public static string Password(this Randomizer randomizer, int length = 12) => randomizer.String2(length, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-==+`~"); } diff --git a/tests/FunderMaps.IntegrationTests/Faker/InquiryDtoFaker.cs b/tests/FunderMaps.IntegrationTests/Faker/InquiryDtoFaker.cs index bba778833..f3e5b5b38 100644 --- a/tests/FunderMaps.IntegrationTests/Faker/InquiryDtoFaker.cs +++ b/tests/FunderMaps.IntegrationTests/Faker/InquiryDtoFaker.cs @@ -1,5 +1,4 @@ using Bogus; -using Bogus.DataSets; using Bogus.Extensions; using FunderMaps.Core.Types; using FunderMaps.WebApi.DataTransferObjects; @@ -24,7 +23,7 @@ public InquiryDtoFaker() RuleFor(f => f.FloorMeasurement, f => f.Random.Bool()); RuleFor(f => f.Note, f => f.Lorem.Text().OrNull(f, .7f)); RuleFor(f => f.DocumentDate, f => f.Date.Between(DateTime.Parse("1000-01-01"), DateTime.Now)); - RuleFor(f => f.DocumentFile, f => f.Internet.RemoteFileWithSecureUrl()); + RuleFor(f => f.DocumentFile, f => f.System.FileName()); RuleFor(f => f.Type, f => f.PickRandom()); RuleFor(f => f.StandardF3o, f => f.Random.Bool(0.3f)); RuleFor(f => f.AuditStatus, f => f.PickRandom()); diff --git a/tests/FunderMaps.IntegrationTests/Faker/OrganizationDtoFaker.cs b/tests/FunderMaps.IntegrationTests/Faker/OrganizationDtoFaker.cs index ff0f57bcb..039876e76 100644 --- a/tests/FunderMaps.IntegrationTests/Faker/OrganizationDtoFaker.cs +++ b/tests/FunderMaps.IntegrationTests/Faker/OrganizationDtoFaker.cs @@ -1,5 +1,4 @@ using Bogus; -using Bogus.DataSets; using Bogus.Extensions; using FunderMaps.AspNetCore.DataTransferObjects; using FunderMaps.Core.Entities; @@ -21,7 +20,7 @@ public OrganizationDtoFaker() RuleFor(f => f.Name, f => f.Company.CompanyName()); RuleFor(f => f.Email, (f, o) => f.Internet.Email(provider: o.Name)); RuleFor(f => f.PhoneNumber, f => f.Phone.PhoneNumber("###########").OrNull(f, .3f)); - RuleFor(f => f.BrandingLogo, f => f.Internet.RemoteFileWithSecureUrl()); + RuleFor(f => f.BrandingLogo, f => f.Image.PicsumUrl()); RuleFor(f => f.HomeStreet, f => f.Address.StreetName()); RuleFor(f => f.HomeAddressNumber, f => Convert.ToInt32(f.Address.BuildingNumber())); RuleFor(f => f.HomeAddressNumberPostfix, f => f.Address.SecondaryAddress()); diff --git a/tests/FunderMaps.IntegrationTests/Faker/RecoveryDtoFaker.cs b/tests/FunderMaps.IntegrationTests/Faker/RecoveryDtoFaker.cs index fefa21576..6da23566e 100644 --- a/tests/FunderMaps.IntegrationTests/Faker/RecoveryDtoFaker.cs +++ b/tests/FunderMaps.IntegrationTests/Faker/RecoveryDtoFaker.cs @@ -21,7 +21,7 @@ public RecoveryDtoFaker() RuleFor(f => f.DocumentName, f => f.System.FileName()); RuleFor(f => f.Note, f => f.Lorem.Text().OrNull(f, .8f)); RuleFor(f => f.Type, f => f.PickRandom()); - RuleFor(f => f.DocumentFile, f => f.Internet.RemoteFileWithSecureUrl()); + RuleFor(f => f.DocumentFile, f => f.System.FileName()); RuleFor(f => f.DocumentDate, f => f.Date.Between(DateTime.Parse("1000-01-01"), DateTime.Now)); RuleFor(f => f.AuditStatus, f => f.PickRandom()); RuleFor(f => f.Reviewer, f => f.Random.Uuid().OrNull(f, 0.2f)); diff --git a/tests/FunderMaps.IntegrationTests/Faker/UserFaker.cs b/tests/FunderMaps.IntegrationTests/Faker/UserFaker.cs index f5c316670..273252d34 100644 --- a/tests/FunderMaps.IntegrationTests/Faker/UserFaker.cs +++ b/tests/FunderMaps.IntegrationTests/Faker/UserFaker.cs @@ -1,9 +1,6 @@ using Bogus; -using Bogus.Extensions; using FunderMaps.Core.Entities; -using FunderMaps.Core.Types; using System.Collections.Generic; -using System.Linq; namespace FunderMaps.IntegrationTests.Faker { @@ -106,20 +103,5 @@ public class UserFaker : Faker "web designer", "writer", }; - - /// - /// Create new instance. - /// - public UserFaker() - { - RuleFor(f => f.Id, f => f.Random.Uuid()); - RuleFor(f => f.GivenName, f => f.Person.FirstName.OrNull(f, .1f)); - RuleFor(f => f.LastName, f => f.Person.LastName.OrNull(f, .1f)); - RuleFor(f => f.Email, f => f.Person.Email); - RuleFor(f => f.Avatar, f => f.Person.Avatar.OrNull(f, .8f)); - RuleFor(f => f.JobTitle, f => f.Random.ArrayElement(jobs.ToArray())); - RuleFor(f => f.PhoneNumber, f => f.Phone.PhoneNumber("###########").OrNull(f, .5f)); - RuleFor(f => f.Role, f => f.PickRandom()); - } } } diff --git a/tests/FunderMaps.IntegrationTests/FixtureFactory.cs b/tests/FunderMaps.IntegrationTests/FixtureFactory.cs index 4a8dee0c9..df578aa15 100644 --- a/tests/FunderMaps.IntegrationTests/FixtureFactory.cs +++ b/tests/FunderMaps.IntegrationTests/FixtureFactory.cs @@ -13,6 +13,7 @@ public abstract class FixtureFactory : IAsyncLifetime private AuthFunderMapsWebApplicationFactory verifierAppClient; private AuthFunderMapsWebApplicationFactory writerAppClient; private AuthFunderMapsWebApplicationFactory readerAppClient; + private AuthFunderMapsWebApplicationFactory alterAppClient; public async Task InitializeAsync() { @@ -22,17 +23,22 @@ public async Task InitializeAsync() verifierAppClient = new(client, "Freda@contoso.com", "fundermaps"); writerAppClient = new(client, "patsy@contoso.com", "fundermaps"); readerAppClient = new(client, "lester@contoso.com", "fundermaps"); + alterAppClient = new(client, "corene@contoso.com", "fundermaps"); await adminAppClient.InitializeAsync(); await superuserAppClient.InitializeAsync(); await verifierAppClient.InitializeAsync(); await writerAppClient.InitializeAsync(); await readerAppClient.InitializeAsync(); + await alterAppClient.InitializeAsync(); } public HttpClient CreateAdminClient() => adminAppClient.CreateClient(); + public HttpClient CreateAlterClient() + => alterAppClient.CreateClient(); + public HttpClient CreateClient(OrganizationRole role = OrganizationRole.Reader) => role switch { diff --git a/tests/FunderMaps.IntegrationTests/FunderMaps.IntegrationTests.csproj b/tests/FunderMaps.IntegrationTests/FunderMaps.IntegrationTests.csproj index 384fcc3f4..d87a518b8 100644 --- a/tests/FunderMaps.IntegrationTests/FunderMaps.IntegrationTests.csproj +++ b/tests/FunderMaps.IntegrationTests/FunderMaps.IntegrationTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/tests/FunderMaps.IntegrationTests/Portal/IncidentPortalTests.cs b/tests/FunderMaps.IntegrationTests/Portal/IncidentPortalTests.cs index 7a8099ea2..81c380e6b 100644 --- a/tests/FunderMaps.IntegrationTests/Portal/IncidentPortalTests.cs +++ b/tests/FunderMaps.IntegrationTests/Portal/IncidentPortalTests.cs @@ -25,70 +25,110 @@ public IncidentPortalTests(PortalWebApplicationFactory factory) => Factory = factory; [Fact] - public async Task CreateIncidentReturnOk() + public async Task UploadDocumentReturnDocument() { // Arrange - var incident = new IncidentDtoFaker() - .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") - .Generate(); + using var formContent = new FileUploadContent(mediaType: "application/pdf", fileExtension: "pdf"); using var client = Factory.CreateClient(); // Act - var response = await client.PostAsJsonAsync("api/incident-portal/submit", incident); + var response = await client.PostAsync("api/incident-portal/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); // Assert - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.NotNull(returnObject.Name); } - [Theory] - [InlineData("gfm-asdkkgfsljshdf")] - [InlineData("aaa-invalidid")] - [InlineData("gfm-correctid")] - public async Task CreateIncidentReturnNotFound(string address) + [Fact] + public async Task UploadEmptyFormReturnBadRequest() { - // Arrange. - var incident = new IncidentDtoFaker() - .RuleFor(f => f.Address, f => address) - .Generate(); + // Arrange + using var formContent = new MultipartFormDataContent(); using var client = Factory.CreateClient(); - // Act. - var response = await client.PostAsJsonAsync("api/incident-portal/submit", incident); + // Act + var response = await client.PostAsync("api/incident-portal/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); - // Assert. - Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); + // Assert + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); } [Fact] - public async Task UploadDocumentReturnDocument() + public async Task UploadEmptyDocumentReturnBadRequest() { // Arrange - using var formContent = new FileUploadContent(mediaType: "application/pdf", fileExtension: "pdf"); + using var formContent = new FileUploadContent( + mediaType: "application/pdf", + fileExtension: "pdf", + byteContentLength: 0); using var client = Factory.CreateClient(); // Act var response = await client.PostAsync("api/incident-portal/upload-document", formContent); - var returnObject = await response.Content.ReadFromJsonAsync(); + var returnObject = await response.Content.ReadFromJsonAsync(); // Assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.NotNull(returnObject.Name); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); } - [Theory] - [InlineData("gfm-9627e072a5ce4e31a051242d51e0ef3a")] - public async Task GetRiskAnalysisReturnAnalysis(string address) + [Fact] + public async Task UploadForbiddenDocumentReturnBadRequest() { // Arrange + using var formContent = new FileUploadContent( + mediaType: "font/woff", + fileExtension: "woff"); using var client = Factory.CreateClient(); // Act - var response = await client.GetAsync($"api/incident-portal/risk?id={address}"); - var returnObject = await response.Content.ReadFromJsonAsync>(); + var response = await client.PostAsync("api/incident-portal/upload-document", formContent); + var returnObject = await response.Content.ReadFromJsonAsync(); // Assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.NotNull(returnObject[0].NeighborhoodId); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); + Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public async Task CreateIncidentReturnOk() + { + // Arrange + var incident = new IncidentDtoFaker() + .RuleFor(f => f.Address, f => "gfm-351cc5645ab7457b92d3629e8c163f0b") + .Generate(); + using var client = Factory.CreateClient(); + + // Act + var response = await client.PostAsJsonAsync("api/incident-portal/submit", incident); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + } + + [Theory] + [InlineData("gfm-asdkkgfsljshdf")] + [InlineData("aaa-invalidid")] + [InlineData("gfm-correctid")] + public async Task CreateIncidentReturnNotFound(string address) + { + // Arrange. + var incident = new IncidentDtoFaker() + .RuleFor(f => f.Address, f => address) + .Generate(); + using var client = Factory.CreateClient(); + + // Act. + var response = await client.PostAsJsonAsync("api/incident-portal/submit", incident); + + // Assert. + Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); } [Theory] @@ -223,60 +263,20 @@ public async Task CreateEmptyBodyReturnBadRequest() Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } - [Fact] - public async Task UploadEmptyFormReturnBadRequest() - { - // Arrange - using var formContent = new MultipartFormDataContent(); - using var client = Factory.CreateClient(); - - // Act - var response = await client.PostAsync("api/incident-portal/upload-document", formContent); - var returnObject = await response.Content.ReadFromJsonAsync(); - - // Assert - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); - Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); - } - - [Fact] - public async Task UploadEmptyDocumentReturnBadRequest() - { - // Arrange - using var formContent = new FileUploadContent( - mediaType: "application/pdf", - fileExtension: "pdf", - byteContentLength: 0); - using var client = Factory.CreateClient(); - - // Act - var response = await client.PostAsync("api/incident-portal/upload-document", formContent); - var returnObject = await response.Content.ReadFromJsonAsync(); - - // Assert - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); - Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); - } - - [Fact] - public async Task UploadForbiddenDocumentReturnBadRequest() + [Theory] + [InlineData("gfm-9627e072a5ce4e31a051242d51e0ef3a")] + public async Task GetRiskAnalysisReturnAnalysis(string address) { // Arrange - using var formContent = new FileUploadContent( - mediaType: "font/woff", - fileExtension: "woff"); using var client = Factory.CreateClient(); // Act - var response = await client.PostAsync("api/incident-portal/upload-document", formContent); - var returnObject = await response.Content.ReadFromJsonAsync(); + var response = await client.GetAsync($"api/incident-portal/risk?id={address}"); + var returnObject = await response.Content.ReadFromJsonAsync>(); // Assert - Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); - Assert.Equal((short)HttpStatusCode.BadRequest, returnObject.Status); - Assert.Contains("validation", returnObject.Title, StringComparison.InvariantCultureIgnoreCase); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.NotNull(returnObject[0].NeighborhoodId); } } }