Skip to content

Commit 16238c8

Browse files
authored
Merge pull request #526 from bcgov/development
Merge to master - various features and fixes
2 parents 6b2514f + adcf1d0 commit 16238c8

File tree

64 files changed

+2989
-1289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2989
-1289
lines changed

docs/onboarding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ To watch for source file changes and rebuild the back-end during local developme
176176
| `src/back-end/lib/hooks/code-with-us.ts` | A hook that automatically marks Code With Us opportunities as ready for evaluation. This hook is run on a per-request basis and is throttled to limit resource utilization. |
177177
| `src/back-end/lib/hooks/logger.ts` | A hook that logs each request and response. |
178178
| `src/back-end/lib/hooks/sprint-with-us.ts` | A hook that automatically marks Sprint With Us opportunities as ready for evaluation. This hook is run on a per-request basis and is throttled to limit resource utilization. |
179-
| `src/back-end/lib/mailer/notifications/` | Modules that export individual email notifications. |
179+
| `src/back-end/lib/mailer/notifications/` | Modules that export individual email notifications. **Note:** There is a discrepancy in how contract dates are displayed in opportunity award emails across the three opportunity types. CWU opportunities have `startDate` and `completionDate` fields but do not include them in award emails, while TWU opportunities include them. |
180180
| `src/back-end/lib/mailer/index.tsx` | Exports general types for representing transactional emails. |
181181
| `src/back-end/lib/mailer/templates.tsx` | Exports types, functions and React views for rendering email notifications. |
182182
| `src/back-end/lib/mailer/transport.ts` | Exports types and functions for sending transactional emails using `nodemailer`. |

docs/smoke-testing/2022-12-02.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
| 52. | Username links to organization for admin in awarded proponent list item in summary | 1. Find an opportunity awarded to an organization 2. Click the organization name beside awarded proponent | Organization's profile is displayed | User's profile was displayed |
5757
| 53. | Username links to user for admin in submitted by list item in summary | 1. Find an awarded opportunity 2. Click the user's name beside submitted by | User's profile is displayed | User's profile was displayed |
5858
| 54. | Admins view different set of opportunity badges | 1. Click Opportunities in the nav bar 2. Create an opportunity 3. Return to Opportunities | Published opportunity badge is visible | Published opportunity badge was visible |
59-
| 55. | Admins can edit, suspend, or cancel a published opportunity | 1. Click Opportunities in the nav bar 2. Select a published opportunity 3. Select Opportunity 4. Click actions | The actions Edit, Suspend, and Cancel are displayed | The actions Edit, Suspend, and Cancel were displayed |
60-
| 56. | Admins can publish, edit, or cancel a suspended opportunity | 1. Click Opportunities in the nav bar 2. Select a suspended opportunity 3. Select Opportunity 4. Click actions | The actions Publish, Edit, and Cancel are displayed | The actions Publish, Edit, and Cancel were displayed |
59+
| 55. | Admins can edit, or cancel a published opportunity | 1. Click Opportunities in the nav bar 2. Select a published opportunity 3. Select Opportunity 4. Click actions | The actions Edit and Cancel are displayed | The actions Edit and Cancel were displayed |
60+
| 56. | [REMOVED] Admins can publish, edit, or cancel a suspended opportunity | 1. Click Opportunities in the nav bar 2. Select a suspended opportunity 3. Select Opportunity 4. Click actions | The actions Publish, Edit, and Cancel are displayed | The actions Publish, Edit, and Cancel were displayed |
6161
| 57. | Admins can cancel an opportunity during evaluation | N/A Cannot access submit proposal | The cancel action is displayed | The cancel action was not displayed |
6262
| 58. | Username links to user for opportunity creator in editing tab | 1. Click Opportunities in the nav bar 2. Select an opportunity 3. Select Opportunity 4. Click user's name next to Created By | User's profile is displayed | User's profile is displayed |
6363
| 59. | Admins are notified if an organization hasn't accepted SWU terms | 1. Click Organizations in the nav bar 2. Select an organization that hasn't accepted SWU terms | Notification that the organization hasn't accepted is displayed | Notification that the organization hasn't accepted was displayed |
@@ -70,13 +70,13 @@
7070
| 66. | Mailer notifies on CWU publish | 1. Publish a CWU opportunity | Mailer sends an email notifying CWU opportunity is published | Mailer sends an email notifying CWU opportunity is published |
7171
| 67. | Mailer notifies on CWU update | 1. Edit a CWU opportunity | Mailer sends an email notifying CWU opportunity is updated | Mailer sends an email notifying CWU opportunity was updated |
7272
| 68. | Mailer notifies on CWU cancellation | 1. Cancel a CWU opportunity | Mailer sends an email notifying CWU opportunity is cancelled | Mailer sends an email notifying CWU opportunity was cancelled |
73-
| 69. | Mailer notifies on CWU suspension | 1. Suspend a CWU opportunity | Mailer sends an email notifying CWU opportunity is suspended | Mailer sends an email notifying CWU opportunity was suspended |
73+
| 69. | [REMOVED] Mailer notifies on CWU suspension | 1. Suspend a CWU opportunity | Mailer sends an email notifying CWU opportunity is suspended | Mailer sends an email notifying CWU opportunity was suspended |
7474
| 70. | Mailer notifies when CWU ready for evaluation | 1. Wait for an opportunity to close | Mailer sends an email notifying CWU opportunity is ready for evaluation | Mailer sends an email notifying CWU opportunity was ready for evaluation |
7575
| 71. | Mailer notifies when SWU submitted for review | 1. Create a SWU opportunity as a non-admin | Mailer sends an email notifying SWU opportunity has been submitted for review | Mailer sends an email notifying SWU opportunity has been submitted for review |
7676
| 72. | Mailer notifies on SWU publish | 1. Publish a SWU opportunity | Mailer sends an email notifying SWU opportunity is published | Mailer sends an email notifying SWU opportunity is published |
7777
| 73. | Mailer notifies on SWU update | 1. Edit a SWU opportunity | Mailer sends an email notifying SWU opportunity is updated | Mailer sends an email notifying SWU opportunity was updated |
7878
| 74. | Mailer notifies on SWU cancellation | 1. Cancel a SWU opportunity | Mailer sends an email notifying SWU opportunity is cancelled | Mailer sends an email notifying SWU opportunity was cancelled |
79-
| 75. | Mailer notifies on SWU suspension | 1. Suspend a SWU opportunity | Mailer sends an email notifying SWU opportunity is suspended | Mailer sends an email notifying SWU opportunity was suspended |
79+
| 75. | [REMOVED] Mailer notifies on SWU suspension | 1. Suspend a SWU opportunity | Mailer sends an email notifying SWU opportunity is suspended | Mailer sends an email notifying SWU opportunity was suspended |
8080
| 76. | Mailer notifies when SWU ready for evaluation | 1. Wait for an opportunity to close | Mailer sends an email notifying SWU opportunity is ready for evaluation | Mailer sends an email notifying SWU opportunity was ready for evaluation |
8181
| 77. | Mailer notifies when CWU proposal submitted | 1. Submit a proposal to a CWU opportunity | Mailer sends an email notifying CWU proposal is submitted | Mailer sends an email notifying CWU proposal was submitted |
8282
| 78. | Mailer notifies when CWU proposal submitted | 1. Submit a proposal to a CWU opportunity | Mailer sends an email notifying CWU proposal is submitted | Mailer sends an email notifying CWU proposal was submitted |

src/back-end/docs/opportunities/code-with-us.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,14 @@ paths:
8585
properties:
8686
tag:
8787
type: string
88-
enum: [edit, publish, suspend, cancel, addAddendum]
88+
enum: [edit, publish, cancel, addAddendum]
8989
value:
9090
type: object
9191
examples:
9292
edit:
9393
$ref: "#/components/examples/editCWUOpportunity"
9494
publish:
9595
$ref: "#/components/examples/publishCWUOpportunity"
96-
suspend:
97-
$ref: "#/components/examples/suspendCWUOpportunity"
9896
cancel:
9997
$ref: "#/components/examples/cancelCWUOpportunity"
10098
addAddendum:
@@ -230,12 +228,6 @@ components:
230228
tag: publish
231229
value: Published
232230

233-
suspendCWUOpportunity:
234-
summary: Request body for suspending a Code-With-Us opportunity
235-
value:
236-
tag: suspend
237-
value: Suspended for now
238-
239231
cancelCWUOpportunity:
240232
summary: Request body for canceling a Code-With-Us opportunity
241233
value:

src/back-end/docs/opportunities/sprint-with-us.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ paths:
9292
publish,
9393
startCodeChallenge,
9494
startTeamScenario,
95-
suspend,
9695
cancel,
9796
addAddendum
9897
]
@@ -107,8 +106,6 @@ paths:
107106
$ref: "#/components/examples/startCodeChallengeForSWUOpportunity"
108107
startTeamScenario:
109108
$ref: "#/components/examples/startTeamScenarioForSWUOpportunity"
110-
suspend:
111-
$ref: "#/components/examples/suspendSWUOpportunity"
112109
cancel:
113110
$ref: "#/components/examples/cancelSWUOpportunity"
114111
addAddendum:
@@ -337,12 +334,6 @@ components:
337334
tag: startTeamScenario
338335
value: Team scenario started
339336

340-
suspendSWUOpportunity:
341-
summary: Request body for suspending a Sprint-With-Us opportunity
342-
value:
343-
tag: suspend
344-
value: Suspended for now
345-
346337
cancelSWUOpportunity:
347338
summary: Request body for canceling a Sprint-With-Us opportunity
348339
value:

src/back-end/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import teamWithUsOpportunityResourceQuestionEvaluationResource from "back-end/li
5050
import teamWithUsProposalResourceQuestionConsensusResource from "back-end/lib/resources/proposal/team-with-us/resource-questions/consensus";
5151
import teamWithUsOpportunityResourceQuestionConsensusResource from "back-end/lib/resources/opportunity/team-with-us/resource-questions/consensus";
5252
import userResource from "back-end/lib/resources/user";
53+
import contactListResource from "back-end/lib/resources/contact-list";
5354
import adminRouter from "back-end/lib/routers/admin";
5455
import authRouter from "back-end/lib/routers/auth";
5556
import frontEndRouter from "back-end/lib/routers/front-end";
@@ -167,6 +168,7 @@ export function createRouter(connection: Connection): AppRouter {
167168
ownedOrganizationResource,
168169
sessionResource,
169170
userResource,
171+
contactListResource,
170172
metricsResource,
171173
emailNotificationsResource,
172174
sprintWithUsProposalTeamQuestionEvaluationResource,

src/back-end/lib/db/opportunity/code-with-us.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
CWUOpportunityHistoryRecord,
2121
CWUOpportunitySlim,
2222
CWUOpportunityStatus,
23-
privateOpportunitiesStatuses,
23+
privateOpportunityStatuses,
2424
publicOpportunityStatuses
2525
} from "shared/lib/resources/opportunity/code-with-us";
2626
import {
@@ -309,27 +309,24 @@ export function generateCWUOpportunityQuery(
309309
"cwuOpportunities as opp"
310310
)
311311
// Join on latest CWU status
312-
.join<RawCWUOpportunity>("cwuOpportunityStatuses as stat", function () {
313-
this.on("opp.id", "=", "stat.opportunity").andOn(
314-
"stat.createdAt",
315-
"=",
316-
connection.raw(
317-
'(select max("createdAt") from "cwuOpportunityStatuses" as stat2 where \
318-
stat2.opportunity = opp.id and stat2.status is not null)'
319-
)
320-
);
321-
})
312+
.join(
313+
connection.raw(
314+
`(SELECT DISTINCT ON (opportunity) * FROM "cwuOpportunityStatuses"
315+
WHERE status IS NOT NULL
316+
ORDER BY opportunity, "createdAt" DESC) as stat`
317+
),
318+
"opp.id",
319+
"stat.opportunity"
320+
)
322321
// Join on latest CWU version
323-
.join<RawCWUOpportunity>("cwuOpportunityVersions as version", function () {
324-
this.on("opp.id", "=", "version.opportunity").andOn(
325-
"version.createdAt",
326-
"=",
327-
connection.raw(
328-
'(select max("createdAt") from "cwuOpportunityVersions" as version2 where \
329-
version2.opportunity = opp.id)'
330-
)
331-
);
332-
})
322+
.join(
323+
connection.raw(
324+
`(SELECT DISTINCT ON (opportunity) * FROM "cwuOpportunityVersions"
325+
ORDER BY opportunity, "createdAt" DESC) as version`
326+
),
327+
"opp.id",
328+
"version.opportunity"
329+
)
333330
.select<RawCWUOpportunity[]>(
334331
"opp.id",
335332
"opp.createdAt",
@@ -402,15 +399,15 @@ export const readOneCWUOpportunity = tryDb<
402399
).orWhere(function () {
403400
this.whereIn(
404401
"stat.status",
405-
privateOpportunitiesStatuses as CWUOpportunityStatus[]
402+
privateOpportunityStatuses as CWUOpportunityStatus[]
406403
).andWhere({ "opp.createdBy": session.user?.id });
407404
});
408405
});
409406
} else {
410407
// Admin users can see both private and public opportunities
411408
query = query.whereIn("stat.status", [
412409
...publicOpportunityStatuses,
413-
...privateOpportunitiesStatuses
410+
...privateOpportunityStatuses
414411
]);
415412
}
416413

@@ -622,7 +619,7 @@ export const readManyCWUOpportunities = tryDb<[Session], CWUOpportunitySlim[]>(
622619
.orWhere(function () {
623620
this.whereIn(
624621
"stat.status",
625-
privateOpportunitiesStatuses as CWUOpportunityStatus[]
622+
privateOpportunityStatuses as CWUOpportunityStatus[]
626623
).andWhere({ "opp.createdBy": session.user?.id });
627624
});
628625
}

src/back-end/lib/db/opportunity/sprint-with-us.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -462,27 +462,24 @@ export function generateSWUOpportunityQuery(
462462
"swuOpportunities as opportunities"
463463
)
464464
// Join on latest SWU status
465-
.join("swuOpportunityStatuses as statuses", function () {
466-
this.on("opportunities.id", "=", "statuses.opportunity").andOn(
467-
"statuses.createdAt",
468-
"=",
469-
connection.raw(
470-
'(select max("createdAt") from "swuOpportunityStatuses" as statuses2 where \
471-
statuses2.opportunity = opportunities.id and statuses2.status is not null)'
472-
)
473-
);
474-
})
465+
.join(
466+
connection.raw(
467+
`(SELECT DISTINCT ON (opportunity) * FROM "swuOpportunityStatuses"
468+
WHERE status IS NOT NULL
469+
ORDER BY opportunity, "createdAt" DESC) as statuses`
470+
),
471+
"opportunities.id",
472+
"statuses.opportunity"
473+
)
475474
// Join on latest SWU version
476-
.join("swuOpportunityVersions as versions", function () {
477-
this.on("opportunities.id", "=", "versions.opportunity").andOn(
478-
"versions.createdAt",
479-
"=",
480-
connection.raw(
481-
'(select max("createdAt") from "swuOpportunityVersions" as versions2 where \
482-
versions2.opportunity = opportunities.id)'
483-
)
484-
);
485-
})
475+
.join(
476+
connection.raw(
477+
`(SELECT DISTINCT ON (opportunity) * FROM "swuOpportunityVersions"
478+
ORDER BY opportunity, "createdAt" DESC) as versions`
479+
),
480+
"opportunities.id",
481+
"versions.opportunity"
482+
)
486483
.select<RawSWUOpportunitySlim[]>(
487484
"opportunities.id",
488485
"opportunities.createdAt",

src/back-end/lib/db/opportunity/team-with-us.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -514,27 +514,24 @@ export function generateTWUOpportunityQuery(
514514
"twuOpportunities as opportunities"
515515
)
516516
// Join on latest TWU status
517-
.join("twuOpportunityStatuses as statuses", function () {
518-
this.on("opportunities.id", "=", "statuses.opportunity").andOn(
519-
"statuses.createdAt",
520-
"=",
521-
connection.raw(
522-
'(select max("createdAt") from "twuOpportunityStatuses" as statuses2 where \
523-
statuses2.opportunity = opportunities.id and statuses2.status is not null)'
524-
)
525-
);
526-
})
517+
.join(
518+
connection.raw(
519+
`(SELECT DISTINCT ON (opportunity) * FROM "twuOpportunityStatuses"
520+
WHERE status IS NOT NULL
521+
ORDER BY opportunity, "createdAt" DESC) as statuses`
522+
),
523+
"opportunities.id",
524+
"statuses.opportunity"
525+
)
527526
// Join on latest TWU version
528-
.join("twuOpportunityVersions as versions", function () {
529-
this.on("opportunities.id", "=", "versions.opportunity").andOn(
530-
"versions.createdAt",
531-
"=",
532-
connection.raw(
533-
'(select max("createdAt") from "twuOpportunityVersions" as versions2 where \
534-
versions2.opportunity = opportunities.id)'
535-
)
536-
);
537-
})
527+
.join(
528+
connection.raw(
529+
`(SELECT DISTINCT ON (opportunity) * FROM "twuOpportunityVersions"
530+
ORDER BY opportunity, "createdAt" DESC) as versions`
531+
),
532+
"opportunities.id",
533+
"versions.opportunity"
534+
)
538535
.select<RawTWUOpportunitySlim[]>(
539536
"opportunities.id",
540537
"opportunities.createdAt",

0 commit comments

Comments
 (0)