Skip to content

Commit

Permalink
Merge branch 'main' into feat/guidance-contact-us-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mishraomp authored Jul 30, 2024
2 parents ff8414e + c09ed0f commit cbadbc3
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
--set backend.pdb.enabled=false \
--set frontend.pdb.enabled=false \
--set global.amsURL=https://j200.gov.bc.ca/pub/ams/ \
--set-string backend.env.omrrAppStatusFlag=true \
tests:
name: Tests
needs: [ deploy-test ]
Expand All @@ -66,6 +67,7 @@ jobs:
--set backend.pdb.enabled=false \
--set frontend.pdb.enabled=false \
--set global.amsURL=https://j200.gov.bc.ca/pub/ams/ \
--set-string backend.env.omrrAppStatusFlag=true \
promote:
name: Promote Images
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
--set backend.pdb.enabled=false \
--set frontend.pdb.enabled=false \
--set global.amsURL=https://test.j200.gov.bc.ca/pub/ams/ \
--set-string backend.env.omrrAuthzDocsFlag=true \
tests:
name: Tests
if: needs.deploys.outputs.triggered == 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('AmsOracleConnectorService', () => {
describe('onModuleInit', () => {
it('should initialize AmsOracleConnectorService and call getOMRRDataFromAMS and getOMRRApplicationStatusFromAMS', async () => {
process.env.OMRR_AUTHZ_DOCS_FLAG = 'true';
process.env.OMRR_APP_STATUS_FLAG = 'true';
const getOMRRDataFromAMS = jest
.spyOn(service, 'getOMRRDataFromAMS')
.mockResolvedValue(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { OMRR_AUTHZ_DOCS_QUERY } from './omrr-authz-docs-query'
import { OmrrAuthzDocsQueryResponse, OmrrAuthzDocsResponse } from '../types/omrr-authz-docs-response'

let omrrResponse: OmrrResponse | null = null
let omrrApplicationStatusResponse: OmrrApplicationStatusResponse[] | null = null
let omrrApplicationStatusResponse: OmrrApplicationStatusResponse[] | null = []
let omrrAuthzDocsResponse: OmrrAuthzDocsResponse[] | null = [] // initialize to empty array
const NR_ORACLE_SERVICE_URL = process.env.NR_ORACLE_SERVICE_URL
const NR_ORACLE_SERVICE_KEY = process.env.NR_ORACLE_SERVICE_KEY
Expand Down Expand Up @@ -88,7 +88,7 @@ export class AmsOracleConnectorService implements OnModuleInit {
process.exit(128)
}
}
if (!omrrApplicationStatusResponse) {
if (omrrApplicationStatusResponse.length === 0 && process.env.OMRR_APP_STATUS_FLAG === 'true') {
try {
await this.getOMRRApplicationStatusFromAMS()
} catch (error) {
Expand Down Expand Up @@ -164,19 +164,20 @@ export class AmsOracleConnectorService implements OnModuleInit {
// else create a new document array and add it to the authorization number
const omrrAuthzDocsResponseScoped: OmrrAuthzDocsResponse[] = []
for (const row of result) {
const authNum = row['Authorization Number']
const authNum: number = Number(row['Authorization Number'])
const doc = {
DocumentObjectID: row['DocumentObjectID'],
DocumentObjectID: Number(row['DocumentObjectID']),
Description: row['Description'],
Publiclyviewable: row['Publiclyviewable'],
}
if(omrrAuthzDocsResponseScoped?.length > 0) {
const authNumIndex = omrrAuthzDocsResponseScoped.findIndex((auth) => auth['Authorization Number'] === authNum)
if (authNumIndex === -1) {
omrrAuthzDocsResponseScoped.push({
const omrrAuthzDoc: OmrrAuthzDocsResponse = {
'Authorization Number': authNum,
doc_links: [doc],
})
}
omrrAuthzDocsResponseScoped.push(omrrAuthzDoc)
} else {
omrrAuthzDocsResponseScoped[authNumIndex].doc_links.push(doc)
}
Expand Down
8 changes: 4 additions & 4 deletions backend/src/v1/ams-oracle-connector/omrr-authz-docs-query.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export const OMRR_AUTHZ_DOCS_QUERY = `SELECT AUTHORIZATIONOBJECT.AuthorizationNumber as "Authorization Number",
EM_AuthorizationDocuments.DocumentObjectID,
EM_AuthorizationDocuments.DocumentObjectID AS "DocumentObjectID",
CASE
WHEN EM_AuthorizationDocuments.Description is not null
THEN EM_AuthorizationDocuments.Description
ELSE EM_AuthorizationDocuments.Filename
END As "Description",
EM_AuthorizationDocuments.Publiclyviewable
EM_AuthorizationDocuments.Publiclyviewable AS "Publiclyviewable"
FROM corral_generated_views.authorizationobject,
corral_generated_views.Em_Authorizationdocuments
where authorizationobject.objectID = Em_Authorizationdocuments.authorizationobjectID
UNION ALL
SELECT REGISTRATION.REGAUTHORIZATIONNUMBER as "Authorization Number",
EM_AuthorizationDocuments.DocumentObjectID,
EM_AuthorizationDocuments.DocumentObjectID AS "DocumentObjectID",
CASE
WHEN EM_AuthorizationDocuments.Description is not null
THEN EM_AuthorizationDocuments.Description
ELSE EM_AuthorizationDocuments.Filename
END As "Description",
EM_AuthorizationDocuments.Publiclyviewable
EM_AuthorizationDocuments.Publiclyviewable AS "Publiclyviewable"
FROM CORRAL_GENERATED_VIEWS.REGISTRATION,
corral_generated_views.Em_Authorizationdocuments
where REGISTRATION.ObjectID = Em_Authorizationdocuments.authorizationobjectID`;
4 changes: 3 additions & 1 deletion backend/src/v1/tasks/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class TasksService {
async refreshCache() {
this.logger.log('refresh cache every hour');
await this.amsOracleConnectorService.getOMRRDataFromAMS();
await this.amsOracleConnectorService.getOMRRApplicationStatusFromAMS();
if(process.env.OMRR_APP_STATUS_FLAG === 'true'){
await this.amsOracleConnectorService.getOMRRApplicationStatusFromAMS();
}
if(OMRR_AUTHZ_DOCS_FLAG === 'true') {
await this.amsOracleConnectorService.getOMRRAuthorizationDocumentsFromAMS();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
key: apiKey
- name: OMRR_AUTHZ_DOCS_FLAG
value: {{ .Values.backend.env.omrrAuthzDocsFlag | quote }}
- name: OMRR_APP_STATUS_FLAG
value: {{ .Values.backend.env.omrrAppStatusFlag | quote }}
ports:
- name: http
containerPort: {{ .Values.backend.service.targetPort }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ spec:
- name: LOG_LEVEL
value: "info"
- name: VITE_AMS_URL
value: {{ .Values.global.amsURL }}
value: {{ .Values.global.amsURL | quote }}
- name: VITE_AMS_DOCS_FLAG
value: {{ .Values.backend.env.omrrAuthzDocsFlag | quote }}
ports:
- name: http
containerPort: 3000
Expand Down
3 changes: 2 additions & 1 deletion charts/nr-epd-organics-info/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ backend:
memory: 100Mi
containerResources:
limits:
cpu: 60m
cpu: 50m
memory: 200Mi
requests:
cpu: 30m
Expand All @@ -69,6 +69,7 @@ backend:
minAvailable: 1 # the minimum number of pods that must be available during the disruption budget.
env:
omrrAuthzDocsFlag: "false"
omrrAppStatusFlag: "false"

frontend:
# -- enable or disable a component deployment.
Expand Down
2 changes: 1 addition & 1 deletion frontend/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
header {
Content-Type text/javascript
}
respond `window.config={"VITE_AMS_URL":"{$VITE_AMS_URL}"};`
respond `window.config={"VITE_AMS_URL":"{$VITE_AMS_URL}", "VITE_AMS_DOCS_FLAG":"{$VITE_AMS_DOCS_FLAG}"};`
}
root * /srv
encode zstd gzip
Expand Down
Binary file modified frontend/public/favicon.ico
Binary file not shown.
12 changes: 8 additions & 4 deletions frontend/src/pages/authorizationDetails/DocumentsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Stack, Typography } from '@mui/material'
import { Link, Stack, Typography } from '@mui/material'
import {env} from '@/env'
import clsx from 'clsx'

import {
Expand All @@ -23,7 +24,7 @@ export function DocumentsSection({ item }: Readonly<Props>) {

const count = documents.length
// When the documents can be downloaded - change to a link
const canDownload = false
const canDownload = env.VITE_AMS_DOCS_FLAG === 'true'
return (
<Stack
direction="column"
Expand All @@ -48,15 +49,18 @@ export function DocumentsSection({ item }: Readonly<Props>) {
</div>
)}
{documents.map((doc: OmrrAuthzDocs) => (
<div
<Link
key={`DocumentRow-${doc.DocumentObjectID}`}
className={clsx(
'documents-table-cell',
canDownload && 'documents-table-cell--link',
)}
href={env.VITE_AMS_URL +'download.aspx?PosseObjectId='+ doc.DocumentObjectID}
target="_blank"
rel={canDownload ? 'noopener noreferrer' : ''}
>
{doc.Description}
</div>
</Link>
))}
</Stack>
</Stack>
Expand Down

0 comments on commit cbadbc3

Please sign in to comment.