-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to deep GET /proposals/{proposalId}
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
- Loading branch information
Showing
11 changed files
with
579 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/database/queries/applicationFormFields/selectByProposalId.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT aff.id AS "id", | ||
aff.application_form_id AS "applicationFormId", | ||
aff.canonical_field_id AS "canonicalFieldId", | ||
aff.position AS "position", | ||
aff.label AS "label", | ||
aff.created_at AS "createdAt" | ||
FROM application_form_fields aff | ||
INNER JOIN proposal_field_values pfv | ||
ON pfv.application_form_field_id = aff.id | ||
INNER JOIN proposal_versions pv | ||
ON pv.id = pfv.proposal_version_id | ||
WHERE pv.proposal_id = :proposalId | ||
ORDER BY pv.version DESC, pfv.position; |
11 changes: 11 additions & 0 deletions
11
src/database/queries/proposalFieldValues/selectByProposalId.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SELECT pfv.id AS "id", | ||
pfv.proposal_version_id AS "proposalVersionId", | ||
pfv.application_form_field_id AS "applicationFormFieldId", | ||
pfv.value AS "value", | ||
pfv.position AS "position", | ||
pfv.created_at AS "createdAt" | ||
FROM proposal_field_values pfv | ||
INNER JOIN proposal_versions pv | ||
ON pv.id = pfv.proposal_version_id | ||
WHERE pv.proposal_id = :proposalId | ||
ORDER BY pv.version DESC, pfv.position; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SELECT pv.id AS "id", | ||
pv.proposal_id AS "proposalId", | ||
pv.application_form_id AS "applicationFormId", | ||
pv.version AS "version", | ||
pv.created_at AS "createdAt" | ||
FROM proposal_versions pv | ||
WHERE pv.proposal_id = :proposalId | ||
ORDER BY pv.version DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export class AuthenticationError extends Error { | ||
public constructor( | ||
message: string, | ||
) { | ||
super(message); | ||
import { ErrorWithStatus } from './ErrorWithStatus'; | ||
|
||
export class AuthenticationError extends ErrorWithStatus { | ||
public constructor(message: string) { | ||
super(message, 401); | ||
this.name = this.constructor.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export class ErrorWithStatus extends Error { | ||
public readonly status: number; | ||
|
||
public constructor( | ||
message: string, | ||
status: number, | ||
) { | ||
super(message); | ||
this.name = this.constructor.name; | ||
this.status = status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ErrorWithStatus } from './ErrorWithStatus'; | ||
|
||
export class NotFoundError extends ErrorWithStatus { | ||
public constructor(message: string) { | ||
super(message, 404); | ||
this.name = this.constructor.name; | ||
} | ||
} |
Oops, something went wrong.