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
Add option to deep GET /proposals/{proposalId} #210
Conversation
Codecov ReportBase: 96.44% // Head: 95.74% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #210 +/- ##
==========================================
- Coverage 96.44% 95.74% -0.71%
==========================================
Files 47 48 +1
Lines 704 775 +71
Branches 125 143 +18
==========================================
+ Hits 679 742 +63
- Misses 24 32 +8
Partials 1 1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
f8105b4
to
fcd5ea6
Compare
fcd5ea6 rebased on main, moved a comment, clarified a comment, made SQL more consistent (caps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to improve the ugliness in mergeApplicationFormFields
.
fcd5ea6
to
abc0291
Compare
abc0291 uses |
abc0291
to
6ce9d01
Compare
6ce9d01 improves test coverage by removing a couple of redundant lines and adding some unit tests. |
6ce9d01
to
c9e413b
Compare
c9e413b improves test coverage and improves a couple of comments. |
c9e413b
to
42a1e98
Compare
42a1e98 improves test coverage and rebases on main. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial feedback -- I have some more but wanted to start with this to see what you think first.
I believe that things could be a bit simpler -- we don't need the decorator / merge functions to be in terms of the PROPOSAL but rather in terms of the object actually being decorated (e.g. the version, the field value, etc). This then saves a whole lot of internal checks and assumptions.
I think this would result in much more concise code with less need for checking / thrown errors while ALSO making those decorator functions universal / relevant to future deep object queries (and the deep query endpoint implementations will just be a matter of getting the data and calling the decorators in the right order!)
42a1e98
to
c602b6a
Compare
c602b6a has most of the suggested changes. I spent way too long trying to figure out how to convince jest to only throw an error on the second call to |
c602b6a
to
ca13026
Compare
ca13026
to
0d56542
Compare
0d56542 rebased on main. |
0d56542
to
9b3bdb1
Compare
9b3bdb1 rebased on main. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great thank you so much for all the iteration!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack so sorry -- so the code looks excellent, but I'm now seeing test coverage isn't 100% (unless I'm being lied to by codecov which has happened before)
That said, it occurs to me that we might consider helper functions that invoke the query and parse the result, which are then tested in isolation and reused across our endpoints rather than having to test every single endpoint... If you prefer we could just open an issue to take on that debt separately -- it would just mean coverage goes down for the short term but we commit to bringing it back up with that refactor (I can take on the refactor).
I'm imagining something like this, but more database specific: https://github.com/PermanentOrg/permanent-sdk/blob/main/src/utils/typedJsonParse.ts
Since I could not get that extra one percent in 4 hours I judged it not worth it because we have 80% coverage already, this also has >80% coverage on new code, and does not reduce the coverage by 2%. The utility/helper function idea might be a more straightforward way to get the coverage rather than mocking only the second |
Yeah absolutely -- I'll update back to approve and create an issue! Thanks for considering it (and for the very legit pushback) |
When optional query parameter includeFieldsAndValues is set to true on GET /proposals/{proposalId}, include all proposal versions, associated values, and associated application form fields in the response. By returning this almost-fully-deep object tree, it is more convenient for the caller and more efficient in terms of request, query, and response counts. The assumption is that the purpose of the PDC is to see and compare which fields are used for what purpose for proposals. This commit consolidates incremental changes that should be seen here: #210 Issue #101 Implement GET /proposals/{proposalId} endpoint
9b3bdb1
to
551be26
Compare
551be26 squashed the two commits into one. |
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. Issue #132 Provide visibility of application form fields
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. Issue #132 Provide visibility of application form fields
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. Issue #132 Provide visibility of application form fields
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. This commit combines four commits from 2022-12-06, 2022-12-12, 2022-12-12, 2022-12-16, 2023-02-09, respectively, and cleanup on 2023-02-13. Some history of changes should be available at #157 Issue #132 Provide visibility of application form fields
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. This commit combines four commits from 2022-12-06, 2022-12-12, 2022-12-12, 2022-12-16, 2023-02-09, respectively, and cleanup on 2023-02-13. Some history of changes should be available at #157 Issue #132 Provide visibility of application form fields
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. This commit combines four commits from 2022-12-06, 2022-12-12, 2022-12-12, 2022-12-16, 2023-02-09, respectively, and cleanup on 2023-02-13. Some history of changes should be available at #157 Issue #132 Provide visibility of application form fields
Use query parameter `includeFields=true` to include application form fields in the response from `GET /applicationForms/{id}`, otherwise a shallow response with only direct attributes on application form will be returned. The implementation is more akin to the one for /proposals in PR #210. This commit combines four commits from 2022-12-06, 2022-12-12, 2022-12-12, 2022-12-16, 2023-02-09, respectively, and cleanup on 2023-02-13. Some history of changes should be available at #157 Issue #132 Provide visibility of application form fields
Without this change, a non-deterministic sort order can cause an HTTP 500 response with message "...values and fields must be sorted...". With this change, the sort order is first by position (as before) and then also by proposal field value (pfv) ID because there can be many pfv rows for a given application form field (aff) row. This should be sufficient to guarantee deterministic order such that the application join will succeed. Issue #381 Unexpected 500 response: "values and fields must be sorted" See also #198 and #210.
Without this change, a non-deterministic sort order can cause an HTTP 500 response with message "...values and fields must be sorted...". With this change, the sort order is first by position (as before) and then also by proposal field value (pfv) ID because there can be many pfv rows for a given application form field (aff) row. This should be sufficient to guarantee deterministic order such that the application join will succeed. Issue #381 Unexpected 500 response: "values and fields must be sorted" See also #198 and #210.
When optional query parameter includeFieldsAndValues is set to true on GET /proposals/{proposalId}, include all proposal versions, associated values, and associated application form fields in the response.
By returning this almost-fully-deep object tree, it is more convenient for the caller and more efficient in terms of request, query, and response counts. The assumption is that the purpose of the PDC is to see and compare which fields are used for what purpose for proposals.
Issue #101 Implement GET /proposals/{proposalId} endpoint
(Alternative approach vs #198)