Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit sampling site fixes #1279

Merged
merged 70 commits into from
May 7, 2024
Merged

Edit sampling site fixes #1279

merged 70 commits into from
May 7, 2024

Conversation

mauberti-bc
Copy link
Collaborator

@mauberti-bc mauberti-bc commented Apr 24, 2024

Links to Jira Tickets

  • N/A
  • Fixes the issue where stratums and blocks cannot be added to a sampling site when editing the site

Description of Changes

  • When a sampling site is edited, the edit page now requests data for that specific sampling site to initialize the formik values
  • Added .kml support for sampling site location file uploads
  • Updated tests for sample-location-repository and the sample location GET endpoint
  • additionalProperties: false is added to the blocks and stratums objects of the sampling site PUT endpoint
  • Renamed methods and periods properties to sample_methods and sample_periods to help reassign types
  • Removed references to surveyed_all_areas, a deprecated field
  • Rearranged survey form files into subdirectories

Testing Notes

  • Should be able to create and edit a sampling site with blocks and stratums
  • Should be able to create and edit sampling sites with .kml

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 34.97758% with 145 lines in your changes are missing coverage. Please review.

Project coverage is 53.12%. Comparing base (f9a9062) to head (d4cf6ae).

Files Patch % Lines
...ites/components/map/SamplingSiteEditMapControl.tsx 0.00% 23 Missing ⚠️
...tions/sampling-sites/edit/SamplingSiteEditPage.tsx 0.00% 15 Missing ⚠️
.../sampling-sites/create/form/SamplingMethodForm.tsx 0.00% 14 Missing ⚠️
api/src/database/db.ts 13.33% 12 Missing and 1 partial ⚠️
.../sampling-sites/edit/form/SampleMethodEditForm.tsx 0.00% 13 Missing ⚠️
...ampling-sites/create/form/SampleSiteCreateForm.tsx 0.00% 8 Missing ⚠️
...s/sampling-strategy/stratums/SurveyStratumForm.tsx 0.00% 7 Missing ⚠️
...s/sampling-sites/edit/form/SamplingStratumForm.tsx 0.00% 7 Missing ⚠️
...urveyId}/sample-site/{surveySampleSiteId}/index.ts 73.91% 5 Missing and 1 partial ⚠️
api/src/repositories/sample-location-repository.ts 53.84% 5 Missing and 1 partial ⚠️
... and 19 more
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1279      +/-   ##
==========================================
+ Coverage   52.91%   53.12%   +0.20%     
==========================================
  Files         564      562       -2     
  Lines       16441    16432       -9     
  Branches     2561     2552       -9     
==========================================
+ Hits         8700     8729      +29     
+ Misses       7159     7119      -40     
- Partials      582      584       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mauberti-bc mauberti-bc requested review from NickPhura and MacQSL April 30, 2024 21:24
@mauberti-bc mauberti-bc added Ready For Review PR is ready for review and removed Early Feedback Welcome PR is not finished, but early review feedback is welcomed labels Apr 30, 2024
@NickPhura
Copy link
Collaborator

NickPhura commented May 1, 2024

Getting an error when I try and load the survey page:

(In this case, I'm loading a default survey generated by the seed)

{
  timestamp: '2024-05-01 14:07:55',
  level: 'error',
  logger: 'paths/project/{projectId}/survey/{surveyId}/view',
  label: 'getSurveyForView',
  message: 'error',
  error: Error executing SQL query: SQL response failed schema check
      at new ApiError (/opt/app-root/src/src/errors/api-error.ts:23:13)
      at new ApiExecuteSQLError (/opt/app-root/src/src/errors/api-error.ts:67:5)
      at parseError (/opt/app-root/src/src/database/db-utils.ts:67:11)
      at Object.sql (/opt/app-root/src/src/database/db-utils.ts:39:13)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async SurveyLocationRepository.getSurveyLocationsData (/opt/app-root/src/src/repositories/survey-location-repository.ts:99:22)
      at async SurveyService.getSurveyById (/opt/app-root/src/src/services/survey-service.ts:83:18)
      at async /opt/app-root/src/src/paths/project/{projectId}/survey/{surveyId}/view.ts:167:26 {
    errors: [
      ZodError: [
        {
          "code": "invalid_type",
          "expected": "object",
          "received": "undefined",
          "path": [
            "rows",
            0,
            "geometry"
          ],
          "message": "Required"
        },
        {
          "code": "invalid_type",
          "expected": "string",
          "received": "undefined",
          "path": [
            "rows",
            0,
            "geography"
          ],
          "message": "Required"
        }
      ]
          at Object.get error [as error] (/opt/app-root/src/node_modules/zod/lib/types.js:55:31)
          at ZodObject.parseAsync (/opt/app-root/src/node_modules/zod/lib/types.js:183:22)
          at processTicksAndRejections (node:internal/process/task_queues:95:5)
          at async Object.sql (/opt/app-root/src/src/database/db-utils.ts:37:14)
          at async SurveyLocationRepository.getSurveyLocationsData (/opt/app-root/src/src/repositories/survey-location-repository.ts:99:22)
          at async SurveyService.getSurveyById (/opt/app-root/src/src/services/survey-service.ts:83:18)
          at async /opt/app-root/src/src/paths/project/{projectId}/survey/{surveyId}/view.ts:167:26 {
        issues: [
          {
            code: 'invalid_type',
            expected: 'object',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          },
          {
            code: 'invalid_type',
            expected: 'string',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          }
        ],
        addIssue: [Function (anonymous)],
        addIssues: [Function (anonymous)],
        errors: [
          {
            code: 'invalid_type',
            expected: 'object',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          },
          {
            code: 'invalid_type',
            expected: 'string',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          }
        ]
      }
    ]
  }
}

@mauberti-bc
Copy link
Collaborator Author

Getting an error when I try and load the survey page:

(In this case, I'm loading a default survey generated by the seed)

{
  timestamp: '2024-05-01 14:07:55',
  level: 'error',
  logger: 'paths/project/{projectId}/survey/{surveyId}/view',
  label: 'getSurveyForView',
  message: 'error',
  error: Error executing SQL query: SQL response failed schema check
      at new ApiError (/opt/app-root/src/src/errors/api-error.ts:23:13)
      at new ApiExecuteSQLError (/opt/app-root/src/src/errors/api-error.ts:67:5)
      at parseError (/opt/app-root/src/src/database/db-utils.ts:67:11)
      at Object.sql (/opt/app-root/src/src/database/db-utils.ts:39:13)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async SurveyLocationRepository.getSurveyLocationsData (/opt/app-root/src/src/repositories/survey-location-repository.ts:99:22)
      at async SurveyService.getSurveyById (/opt/app-root/src/src/services/survey-service.ts:83:18)
      at async /opt/app-root/src/src/paths/project/{projectId}/survey/{surveyId}/view.ts:167:26 {
    errors: [
      ZodError: [
        {
          "code": "invalid_type",
          "expected": "object",
          "received": "undefined",
          "path": [
            "rows",
            0,
            "geometry"
          ],
          "message": "Required"
        },
        {
          "code": "invalid_type",
          "expected": "string",
          "received": "undefined",
          "path": [
            "rows",
            0,
            "geography"
          ],
          "message": "Required"
        }
      ]
          at Object.get error [as error] (/opt/app-root/src/node_modules/zod/lib/types.js:55:31)
          at ZodObject.parseAsync (/opt/app-root/src/node_modules/zod/lib/types.js:183:22)
          at processTicksAndRejections (node:internal/process/task_queues:95:5)
          at async Object.sql (/opt/app-root/src/src/database/db-utils.ts:37:14)
          at async SurveyLocationRepository.getSurveyLocationsData (/opt/app-root/src/src/repositories/survey-location-repository.ts:99:22)
          at async SurveyService.getSurveyById (/opt/app-root/src/src/services/survey-service.ts:83:18)
          at async /opt/app-root/src/src/paths/project/{projectId}/survey/{surveyId}/view.ts:167:26 {
        issues: [
          {
            code: 'invalid_type',
            expected: 'object',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          },
          {
            code: 'invalid_type',
            expected: 'string',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          }
        ],
        addIssue: [Function (anonymous)],
        addIssues: [Function (anonymous)],
        errors: [
          {
            code: 'invalid_type',
            expected: 'object',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          },
          {
            code: 'invalid_type',
            expected: 'string',
            received: 'undefined',
            path: [Array],
            message: 'Required'
          }
        ]
      }
    ]
  }
}

Fixed

NickPhura added 3 commits May 3, 2024 23:04
Fix various endpoints and type definitions to match actual responses.
Misc tweaks/updates/cleanup.
Copy link

sonarqubecloud bot commented May 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
13.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@NickPhura NickPhura merged commit 7ce3576 into dev May 7, 2024
17 of 19 checks passed
@NickPhura NickPhura deleted the sample-site-req branch May 7, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants