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

Add GET proposalVersionById route #1368

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hminsky2002
Copy link
Contributor

Closes #1366

I'll note I did not update the changelog because I wasn't sure if this justified a change (as it wouldn't break anything), but can gladly update if requested!

@hminsky2002 hminsky2002 marked this pull request as ready for review December 5, 2024 23:33
@hminsky2002 hminsky2002 requested a review from slifty December 5, 2024 23:33
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.39%. Comparing base (6902f9d) to head (c79abed).

Files with missing lines Patch % Lines
src/handlers/proposalVersionsHandlers.ts 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1368      +/-   ##
==========================================
+ Coverage   87.34%   87.39%   +0.04%     
==========================================
  Files         185      186       +1     
  Lines        2387     2412      +25     
  Branches      321      325       +4     
==========================================
+ Hits         2085     2108      +23     
- Misses        302      304       +2     

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

@bickelj
Copy link
Contributor

bickelj commented Dec 6, 2024

@hminsky2002 I see you requested @slifty review but I wanted to note the following context. When examining fields from /changemakers, the source does not appear in the response directly, it needs to be found via the proposal version ID (which is present). That is my assumption for why this PR exists: to make it straightforward to find that source.

Copy link
Contributor

@bickelj bickelj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to build, run, and try this code locally. It seemed to work fine. I needed a fresh authentication token to access the endpoint and when I asked for a proposal version by ID I got it back. It looked like the right stuff that I got back. Nothing in the code appears objectionable, at least nothing new objectionable.

My vote is to rebase, push, and merge when the checks pass.

await createApplicationForm({
opportunityId: 1,
});
const newProposalVersion = await createProposalVersion({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this follows some of the existing conventions, and therefore I don't think my objection is reason to hold up this PR, I prefer to get the database-generated IDs explicitly rather than making the assumption that ID 1 was inserted. Something for future PRs, perhaps.

Copy link
Member

@slifty slifty Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and the same can be said for the other IDs referenced here -- it's all being loaded right above so there's no cost to just const opportunity = createOpportunity... and then accessing opportunity.id in the appropriate places.

Also the prefix new here isn't contextually relevant so I'd just call it proposalVersion or testProposalVersion.

"/proposalVersions/{proposalVersionId}": {
"get": {
"operationId": "getProposalVersionById",
"summary": "Gets a specific proposalVersion.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would say "proposal version." instead of "proposalVersion."

"parameters": [
{
"name": "proposalVersionId",
"description": "The PDC-generated ID of a proposalVersion.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would say "proposal version." instead of "proposalVersion."

Copy link
Member

@slifty slifty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small text change request but looks good!

I am approving since I don't need to re-review; I do agree with @bickelj's comments too.

): void => {
const { proposalVersionId } = req.params;
if (!isId(proposalVersionId)) {
next(new InputValidationError('Invalid request body.', isId.errors ?? []));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy pasted error (as in, the error exists in another endpoint so I totally feel for you) -- proposalVersionId is a query parameter, not part of the request body, so this error should be updated to say invalid query parameter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GET ProposalVersion endpoint
3 participants