Skip to content

Commit

Permalink
Release (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnyiri authored Feb 11, 2025
2 parents 475e338 + b3444b7 commit 4ecfbd3
Show file tree
Hide file tree
Showing 300 changed files with 17,032 additions and 8,173 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ jobs:
if: steps.cached-node-modules-backend.outputs.cache-hit != 'true'
run: npm run install:backend

- name: Cache UOWS
id: cached-UOWS
uses: actions/cache@v4
with:
path: apps/backend/generated
key: uows-client-${{ hashFiles('apps/backend/openapi.yaml') }}-${{ env.NODE_VERSION }}

- name: Generate backend UOWS
if: steps.cached-UOWS.outputs.cache-hit != 'true'
run: |
cd apps/backend
npm run generate:uows
- name: Cache frontend node_modules
id: cached-node-modules-frontend
uses: actions/cache@v4
Expand Down Expand Up @@ -159,6 +172,13 @@ jobs:
path: apps/backend/node_modules
key: node-modules-backend-${{ hashFiles('apps/backend/package-lock.json') }}-${{ env.NODE_VERSION }}

- name: Restore backend UOWS
id: cached-UOWS
uses: actions/cache@v4
with:
path: apps/backend/generated
key: uows-client-${{ hashFiles('apps/backend/openapi.yaml') }}-${{ env.NODE_VERSION }}

- name: Restore frontend node_modules
id: cached-node-modules-frontend
uses: actions/cache@v4
Expand All @@ -177,7 +197,7 @@ jobs:
sdk-frontend-
- run: npm ci

- run: npm run build
env:
NODE_ENV: development
Expand All @@ -203,6 +223,13 @@ jobs:
with:
path: apps/backend/node_modules
key: node-modules-backend-${{ hashFiles('apps/backend/package-lock.json') }}-${{ env.NODE_VERSION }}

- name: Restore backend UOWS
id: cached-UOWS
uses: actions/cache@v4
with:
path: apps/backend/generated
key: uows-client-${{ hashFiles('apps/backend/openapi.yaml') }}-${{ env.NODE_VERSION }}

- name: Run backend unit tests
env:
Expand Down Expand Up @@ -241,7 +268,9 @@ jobs:
- id: rs
files: cypress/e2e/[r-s]*.ts
- id: t
files: cypress/e2e/t*.ts
files: cypress/e2e/t!(emplateDeleteAndArchive).ts
- id: templateDelete
files: cypress/e2e/templateDeleteAndArchive*.ts
- id: uz
files: cypress/e2e/[u-z]*.ts
- id: AZ
Expand All @@ -268,6 +297,13 @@ jobs:
with:
path: apps/backend/node_modules
key: node-modules-backend-${{ hashFiles('apps/backend/package-lock.json') }}-${{ env.NODE_VERSION }}

- name: Restore backend UOWS
id: cached-UOWS
uses: actions/cache@v4
with:
path: apps/backend/generated
key: uows-client-${{ hashFiles('apps/backend/openapi.yaml') }}-${{ env.NODE_VERSION }}

- name: Restore frontend node_modules
id: cached-node-modules-frontend
Expand Down Expand Up @@ -343,7 +379,7 @@ jobs:
EMAIL_FOOTER_IMAGE_PATH: /config/logos/STFC-Logo-small.png
EXTERNAL_AUTH_LOGIN_URL: http://localhost:9003/auth/Login.aspx
EXTERNAL_AUTH_LOGOUT_URL: http://localhost:9003/auth/Login.aspx
EXTERNAL_AUTH_SERVICE_URL: http://localhost:1080/ws/UserOfficeWebService?wsdl
EXTERNAL_UOWS_API_URL: http://localhost:1080/users-service
ANTIVIRUS_HOST: clam-antivirus
ANTIVIRUS_PORT: 3310
ISIS_UO_EMAIL: [email protected]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ apps/e2e/node_modules
apps/e2e/cypress/screenshots
apps/backend/node_modules
apps/frontend/src/generated
apps/backend/generated
.DS_Store
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
**/.github/workflows/
**/README.md
**/.vscode/
**/src/generated/
**/generated/

# backend
/apps/backend/src/datasources/stfc/UOWSSoapInterface.ts
/apps/backend/docker-compose-stfc.e2e.yml
/apps/backend/openapi.yaml

# e2e
/apps/e2e/cypress/fixtures/
3 changes: 2 additions & 1 deletion apps/backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
!db_patches
!package*
!tsconfig.json
!index.ts
!index.ts
!openapi.yaml
5 changes: 3 additions & 2 deletions apps/backend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ coverage/*
/src/public/
# custom definition files
/src/types/
# auto-generated SOAP client for the STFC UserOfficeWebService
/src/datasources/stfc/UOWSSoapInterface.ts
# auto-generated REST client for the STFC UserOfficeWebService
openapi.yaml
/generated/
1 change: 1 addition & 0 deletions apps/backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ coverage
.DS_Store
downloads
uploads
generated

.idea

Expand Down
2 changes: 2 additions & 0 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ RUN mkdir -p /home/node/app
WORKDIR /home/node/app

COPY --chown=node:node package*.json ./
COPY openapi.yaml openapi.yaml

RUN npm ci --loglevel error --no-fund
RUN npm run generate:uows

COPY --chown=node:node . .

Expand Down
75 changes: 75 additions & 0 deletions apps/backend/db_patches/0165_AddTechnicalReviewTemplate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
DO
$$
DECLARE
technical_review_template_id_var int;
technical_review_topic_id_var int;
technical_review_loop_var int;
BEGIN
IF register_patch('0165_AddTechnicalReviewTemplate.sql', 'Gergely Nyiri', 'Add Technical review template', '2024-10-15') THEN

INSERT INTO template_categories(template_category_id, name) VALUES(11, 'Technical Review');

INSERT INTO template_groups (template_group_id, category_id) VALUES('TECHNICAL_REVIEW_TEMPLATE', 11);

INSERT INTO question_datatypes(question_datatype_id) VALUES('TECHNICAL_REVIEW_BASIS');

INSERT INTO questions(
question_id,
data_type,
question,
default_config,
natural_key,
category_id
)
VALUES(
'technical_review_basis'
, 'TECHNICAL_REVIEW_BASIS'
, 'Technical review basic information'
, '{"required":false,"small_label":"","tooltip":""}'
, 'technical_review_basis'
, 11
);

ALTER TABLE technical_review ADD COLUMN questionary_id INTEGER REFERENCES questionaries (questionary_id);

ALTER TABLE call ADD COLUMN technical_review_template_id INTEGER REFERENCES templates(template_id);

INSERT INTO templates(name, description, is_archived, group_id) VALUES
('default technical review template', 'default technical review template', false, 'TECHNICAL_REVIEW_TEMPLATE');

SELECT templates.template_id
INTO technical_review_template_id_var
FROM templates
WHERE name='default technical review template';

INSERT INTO topics(topic_title, is_enabled, sort_order, template_id) VALUES('New technical review', TRUE, 0, technical_review_template_id_var);

SELECT topics.topic_id
INTO technical_review_topic_id_var
FROM topics
WHERE topic_title='New technical review';

INSERT INTO templates_has_questions (question_id, template_id, topic_id, sort_order, config) VALUES('technical_review_basis', technical_review_template_id_var, technical_review_topic_id_var, 0, '{"required":false,"small_label":"","tooltip":""}');

UPDATE call set technical_review_template_id = technical_review_template_id_var;

CREATE OR REPLACE FUNCTION CreateTechnicalReviewQuestionary(p_template_id int)
RETURNS integer AS $func$
DECLARE
q_id integer;
BEGIN
INSERT INTO questionaries(template_id) VALUES(p_template_id) RETURNING questionary_id INTO q_id;
RETURN q_id;
END;
$func$ LANGUAGE plpgsql;

FOR technical_review_loop_var IN
SELECT technical_review_id FROM technical_review
LOOP
UPDATE technical_review SET questionary_id = CreateTechnicalReviewQuestionary(technical_review_template_id_var) WHERE technical_review_id = technical_review_loop_var;
END LOOP;

END IF;
END;
$$
LANGUAGE plpgsql;
30 changes: 30 additions & 0 deletions apps/backend/db_patches/0165_AddViewForGenericTemplates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DO
$$
BEGIN
IF register_patch('AddViewForGenericTemplates.sql', 'ellenwright', 'Add new view for generic templates', '2024-11-13') THEN
BEGIN

CREATE VIEW generic_templates_view as select
g.generic_template_id as generic_template_id, g.title, g.creator_id, g.proposal_pk, g.questionary_id, g.question_id, g.created_at,
fr.user_id as fap_reviewer,
fc.user_id as fap_chair,
fs.user_id as fap_secretary,
i.manager_user_id as instrument_manager,
ihs.user_id as scientist_on_proposal,
vu.user_id as visitor

from generic_templates g
left join visits v on v.proposal_pk = g.proposal_pk
left join visits_has_users vu on vu.visit_id = v.visit_id
left join fap_reviews fr on fr.proposal_pk = g.proposal_pk
left join fap_chairs fc on fc.fap_id = fr.fap_id
left join fap_secretaries fs on fs.fap_id = fr.fap_id
left join instrument_has_proposals ihp on ihp.proposal_pk = g.proposal_pk
left join instrument_has_scientists ihs on ihs.instrument_id = ihp.instrument_id
left join instruments i on i.instrument_id = ihp.instrument_id;

END;
END IF;
END;
$$
LANGUAGE plpgsql;
23 changes: 23 additions & 0 deletions apps/backend/db_patches/0166_AddProposalInternalComments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
DO
$$
BEGIN
IF register_patch('0166_AddProposalInternalCommentTable.sql', 'Farai Mutambara', 'Adding proposal internal comment table', '2024-11-29') THEN
BEGIN
CREATE TABLE IF NOT EXISTS proposal_internal_comments (
comment_id SERIAL,
proposal_pk INT REFERENCES proposals(proposal_pk) ON DELETE CASCADE,
comment TEXT NOT NULL,
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY (comment_id, proposal_pk)
);

CREATE TRIGGER set_timestamp
BEFORE UPDATE ON proposal_internal_comments
FOR EACH ROW
EXECUTE PROCEDURE trigger_set_timestamp();

END;
END IF;
END;
$$
LANGUAGE plpgsql;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
DO
$$
BEGIN
IF register_patch('0166_UpdateWhichCommentOnReviewProposalView.sql', 'Thomas Cottee Meldrum', 'Update review column in the view', '2024-12-03') THEN

CREATE OR REPLACE VIEW review_data AS
SELECT proposal.proposal_pk,
proposal.proposal_id,
proposal.title,
proposal.instrument_name,
proposal.availability_time,
proposal.time_allocation,
proposal.fap_id,
proposal.rank_order,
proposal.call_id,
proposal.proposer_id,
proposal.instrument_id,
proposal.fap_time_allocation,
proposal.questionary_id,
grade.avg AS average_grade,
proposal.public_comment as comment
from (
Select
fp.proposal_pk,
p.proposal_id,
p.title,
i.name as instrument_name,
chi.availability_time,
tr.time_allocation,
f.fap_id,
fmd.rank_order,
c.call_id,
p.proposer_id,
i.instrument_id,
fp.fap_time_allocation,
p.questionary_id,
tr.public_comment
from fap_proposals as fp
join faps as f on f.fap_id = fp.fap_id
join call c on c.call_id = fp.call_id
join proposals p on p.proposal_pk = fp.proposal_pk
join technical_review tr on tr.proposal_pk = p.proposal_pk and tr.instrument_id = fp.instrument_id
left join fap_meeting_decisions as fmd on fmd.proposal_pk = p.proposal_pk
join call_has_instruments as chi on chi.instrument_id = fp.instrument_id and chi.call_id = c.call_id
join instruments as i on i.instrument_id = chi.instrument_id
where p.status_id <> 9 and p.status_id <> 1 /* EXPIRED OR DRAFT*/
) as proposal
left join (
Select fr.proposal_pk, AVG(fr.grade) from
fap_proposals as fp
join fap_reviews as fr on fr.proposal_pk = fp.proposal_pk
group by fr.proposal_pk
) as grade on grade.proposal_pk = proposal.proposal_pk;
END IF;
END;
$$
LANGUAGE plpgsql;
30 changes: 30 additions & 0 deletions apps/backend/db_patches/0167_CreateInviteCodes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DO
$$
BEGIN
IF register_patch('0167_CreateInviteCode', 'Jekabs Karklins', 'Adding tables for invites', '2024-12-03') THEN
BEGIN

CREATE TABLE invite_codes (
invite_code_id SERIAL PRIMARY KEY,
code VARCHAR(12) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL,
note TEXT DEFAULT '',
created_by INT NOT NULL REFERENCES users(user_id),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
claimed_by INT REFERENCES users(user_id),
claimed_at TIMESTAMPTZ
);
CREATE INDEX invite_codes_code_idx ON invite_codes(code);

CREATE TABLE role_invites (
role_invite_id SERIAL PRIMARY KEY,
invite_code_id INT NOT NULL REFERENCES invite_codes(invite_code_id) ON DELETE CASCADE,
role_id INT NOT NULL REFERENCES roles(role_id) ON DELETE CASCADE
);
CREATE INDEX role_invites_invite_code_id_idx ON role_invites(invite_code_id);

END;
END IF;
END;
$$
LANGUAGE plpgsql;
14 changes: 14 additions & 0 deletions apps/backend/db_patches/0168_AddCoProposerClaims.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DO
$$
BEGIN
IF register_patch('0168_CreateCoProposerInvite', 'Jekabs Karklins', 'Adding co-proposer claims', '2025-01-10') THEN
BEGIN
CREATE TABLE IF NOT EXISTS co_proposer_invites (
invite_code_id INT NOT NULL REFERENCES invite_codes(invite_code_id) ON DELETE CASCADE,
proposal_pk INT NOT NULL REFERENCES proposals(proposal_pk) ON DELETE CASCADE,
PRIMARY KEY (invite_code_id, proposal_pk));
END;
END IF;
END;
$$
LANGUAGE plpgsql;
11 changes: 11 additions & 0 deletions apps/backend/db_patches/0168_XpressEmailSetting.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DO
$$
BEGIN
IF register_patch('0168_XpressEmailSetting.sql', 'Chi Kai Lam', 'Xpress email setting for recipients SAMPLE_SAFETY_EMAIL', '2025-01-24') THEN
BEGIN
INSERT INTO settings (settings_id, settings_value, description) VALUES ('SAMPLE_SAFETY_EMAIL', '', 'Email address for the sample safety team.');
END;
END IF;
END;
$$
LANGUAGE plpgsql;
Loading

0 comments on commit 4ecfbd3

Please sign in to comment.