Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
f2b8a4c
feat: add new workflow data structures and update related data sources
Dec 22, 2025
29ab668
feat: rename and refactor status changing events handling in workflow…
Dec 22, 2025
b18f078
fix: throw error when status changing event is not found in database
Dec 22, 2025
23b55ba
feat: overhaul workflow status handling by renaming and refactoring r…
Dec 22, 2025
9e33025
feat: overhaul workflow data structures and connections by refactorin…
Dec 24, 2025
2d3b0b6
feat: update WorkflowStatus model and related components to use workf…
Dec 29, 2025
a34a1eb
fix: comment out validation schema for deleteWorkflowStatus and add T…
Dec 29, 2025
3cc35a9
feat: refactor workflow connection handling by renaming methods and i…
Dec 29, 2025
e52d957
feat: update WorkflowEditor to use workflowStatusId for source and ta…
Dec 29, 2025
5d30bee
feat: add ON DELETE CASCADE to foreign key constraints in workflow_st…
Dec 29, 2025
26ef94b
fix: update edge identification logic to use connection ID directly
Dec 29, 2025
f9d1e68
feat: overhaul workflow data structures by removing status changing e…
Dec 29, 2025
ccbcb18
feat: rename and update connection status actions mutation to setStat…
Dec 30, 2025
56b3eb1
refactor: update workflow connection action identifiers to use new na…
Dec 30, 2025
110979a
feat: add ON DELETE CASCADE to foreign key constraints in workflow da…
Dec 30, 2025
51cd7a2
feat: add xstate for workflow state management and implement getWorkf…
Dec 30, 2025
8c563af
feat: enhance workflow management by adding workflow status handling …
Dec 31, 2025
af465b5
refactor: rename updateProposalStatus to updateProposalWfStatus for c…
Dec 31, 2025
b7551ab
feat: overhaul workflow guards by implementing IGuard interface and r…
Dec 31, 2025
50cf348
feat: enhance workflow management by adding default workflow status h…
Dec 31, 2025
ad2becb
refactor: remove unused getProposalWorkflowByCallId function and log …
Jan 1, 2026
d21d38b
feat: overhaul workflow management by replacing IGuard interface with…
Jan 1, 2026
bfd5265
refactor: remove guardNames from WorkflowDataSource and related mock …
Jan 1, 2026
72d06a1
feat: implement workflow machine and guards with refactored state man…
Jan 1, 2026
4f2c8af
feat: enhance workflow management by adding guards and refactoring ev…
Jan 2, 2026
05d2f5a
feat: update workflow and status action data sources to use workflowS…
Jan 2, 2026
44fae96
feat: enhance FapQueries to include review data source and implement …
Jan 2, 2026
dfb2811
refactor: remove unused ProposalEventsRecord interface and clean up w…
Jan 6, 2026
8f56861
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 6, 2026
ba5da92
fix: update join table in CallDataSource to use workflow_has_statuses…
Jan 6, 2026
9e359b5
fix: update edge style logic in WorkflowEdge component for better vis…
Jan 6, 2026
12f1d50
fix: adjust edge style in WorkflowEdge component for improved visibility
Jan 6, 2026
d5695b7
feat: implement ProposalWorkflowEngine and integrate into dependency …
Jan 7, 2026
69322c9
Add guards for proposal workflow validation
Jan 9, 2026
bbec4d3
Refactor status handling in experiments and proposals
Jan 13, 2026
0e66af0
refactor: remove shortCode from Status and related data sources
Jan 14, 2026
e14e955
refactor: replace shortCode with id in status-related data structures…
Jan 14, 2026
6d5ead1
refactor: update workflow and status handling to use 'id' instead of …
Jan 15, 2026
5bb81f9
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 15, 2026
ecce077
refactor: update WorkflowEdge and StatusNode to use 'id' instead of '…
Jan 15, 2026
2301406
feat: add sourceHandle and targetHandle to workflow connections and r…
Jan 15, 2026
b427eef
fix: update status_id to use draftWfStatus for accurate workflow stat…
Jan 15, 2026
606d8de
fix: update workflow handling to use 'id' instead of 'shortCode' for …
Jan 15, 2026
79a7d8b
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 16, 2026
64b3c0b
feat: integrate confirmation dialog for status deletion in StatusNode…
Jan 16, 2026
5ea8316
fix: update status handling to replace 'shortCode' with 'statusId' in…
Jan 21, 2026
809fd48
refactor: overhaul workflow handling by replacing StatusDataSource wi…
Jan 22, 2026
af34c88
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 22, 2026
1876021
Refactor workflow status handling in Cypress tests
Jan 26, 2026
445fee0
refactor: update validation schemas in StatusMutations and WorkflowMu…
Jan 26, 2026
13866d9
refactor: enhance event handling by adding guards for proposal and ca…
Jan 27, 2026
e0052f4
refactor: update proposal and status handling by renaming fields and …
Jan 27, 2026
1aaf880
refactor: update status filter values to use descriptive strings inst…
Jan 27, 2026
206ac10
refactor: update EdgeData interface to use status IDs instead of shor…
Jan 27, 2026
5b99b9f
refactor: update duo-validation package to version 6.0.0 in frontend …
Jan 27, 2026
949c1d0
refactor: overhaul workflow management by enhancing status handling, …
Jan 28, 2026
127255c
refactor: update workflow status handling in FAPs tests to use dynami…
Jan 29, 2026
37aa065
refactor: enhance workflow status management in technique proposal te…
Jan 29, 2026
9ef2bc7
refactor: enable technique proposal and advanced tests by removing skip
Jan 29, 2026
bc91909
refactor: update proposal status input IDs to use 'selectedWorkflowSt…
Jan 29, 2026
64d0ba9
refactor: update proposal status handling to use 'selectedWorkflowSta…
Jan 29, 2026
c452215
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 29, 2026
01c669e
refactor: remove 'only' from create Proposal status test to enable ex…
Jan 29, 2026
4bc3edd
refactor: add status to workflow in proposal tests for improved coverage
Jan 29, 2026
97291fd
refactor: update workflow data structures to link proposals and exper…
Jan 29, 2026
2299355
refactor: enhance workflow status handling by adding 'Feasibility' st…
Jan 29, 2026
5aa2107
refactor: add 'Feasibility' status to workflow and integrate into ins…
Jan 29, 2026
db22382
refactor: add updated_at column to workflows and enhance workflow str…
Jan 29, 2026
d51dd3e
refactor: enhance statusName column rendering with clickable link for…
Jan 29, 2026
5999195
refactor: overhaul workflow data structures and integrate workflow st…
Feb 2, 2026
e7add2d
refactor: streamline workflow status handling by removing position pa…
Feb 3, 2026
112c671
refactor: streamline workflow status handling by removing position pa…
Feb 3, 2026
7d5e3c0
Merge branch 'SWAP-4949-workflow-overhaul' of github.com:UserOfficePr…
Feb 3, 2026
1269421
test: enable proposal allocation time unit test
Feb 3, 2026
09b265a
refactor: optimize SQL query for average grade calculation in proposa…
Feb 3, 2026
7ec3f95
fix: add ORDER BY clause to proposal_pk in status migration query
Feb 3, 2026
db48864
refactor: remove unused event bus publishing functions and caching lo…
Feb 3, 2026
61f310b
fix: cleanup
Feb 3, 2026
0879b7a
fix: update workflow status ID reference in settings tests
Feb 3, 2026
255e798
fix: improve error message for connecting statuses from different wor…
Feb 4, 2026
4426e45
refactor: streamline proposal status handling in settings tests
Feb 4, 2026
0165c16
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Feb 7, 2026
e3685bb
refactor: enhance workflow status handling in settings tests
Feb 8, 2026
a44cb1e
feat: add callEnded parameter to updateCall mutation
Feb 8, 2026
4ddee5a
refactor: update workflow status handling and improve notification me…
Feb 8, 2026
a89838d
refactor: skip proposal status update test for conditional checks
Feb 8, 2026
838d807
test: enable only the proposal workflow status removal test
Feb 8, 2026
6fcab29
refactor: update proposalStatusId handling to support 'ALL' filter
Feb 8, 2026
1f94e5d
feat: enhance proposal status update to validate workflow status befo…
Feb 8, 2026
065411f
feat: add new workflow statuses for Instrument Scientist Review and u…
Feb 8, 2026
9d9b35e
refactor: update workflow status identifiers in tests and components
Feb 8, 2026
eb231c6
feat: add 'EDITABLE_SUBMITTED_INTERNAL' status to workflow and adjust…
Feb 8, 2026
58b49f4
feat: update workflow statuses for Instrument Scientist Review and ad…
Feb 9, 2026
bfc8832
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Feb 13, 2026
a0daa99
feat: rename new workflow data structures and migration scripts for i…
Feb 13, 2026
8d7b5f5
fix: enable setting workflow status ID in ExperimentDataSourceMock
Feb 13, 2026
7bf0eae
feat: refactor StfcProposalDataSource to streamline constructor param…
Feb 13, 2026
7f1d48c
feat: rename 'getDefaultStatus' and 'getDefaultWorkflowStatus' to 'ge…
Feb 13, 2026
8245b1c
fix: change access modifiers for callDataSource and statusDataSource …
Feb 13, 2026
814b407
feat: add notes for workflow status handling and update interface for…
Feb 13, 2026
e89e464
refactor: simplify updated proposals type and remove unnecessary chec…
Feb 13, 2026
83e90fd
feat: expand WorkflowRunInput type to include array of WorkflowRunSin…
Feb 13, 2026
3864a49
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Feb 17, 2026
80f1f66
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Feb 19, 2026
ec5051d
refactor: simplify createWorkflowConnection parameters for improved r…
Feb 22, 2026
3822870
refactor: update validation schemas to use string for IDs and improve…
Feb 22, 2026
03cc3f6
refactor: rename variable for initial workflow status in createExperi…
Feb 22, 2026
e244a61
refactor: remove unused StatusDataSourceMock and update proposal mock…
Feb 22, 2026
399a8f4
refactor: rename newStatus to newWorkflowStatus for clarity in logCon…
Feb 22, 2026
cd603ae
refactor: simplify creation of new proposal workflow connection for i…
Feb 22, 2026
8f94c54
refactor: remove xstate dependency from package.json and package-lock…
Feb 22, 2026
8b888c5
refactor: simplify return statement in getStatusEngineReadyProposals …
Feb 22, 2026
32955c0
refactor: remove hover scaling effect from StyledHandle for consistency
Feb 22, 2026
5d97311
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Feb 24, 2026
232760d
refactor: enhance StyledHandle visibility logic based on connection s…
Feb 24, 2026
31eed77
chore: Seed optimisation
yoganandaness Feb 25, 2026
da0a21f
WIP
yoganandaness Feb 26, 2026
86e1256
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Mar 3, 2026
8333670
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 16, 2026
88a2a54
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 16, 2026
3a7ca72
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 16, 2026
6108815
Merge branch 'SWAP-4949-workflow-overhaul' of github.com:UserOfficePr…
yoganandaness Mar 20, 2026
c5a49eb
fix failing unit tests
yoganandaness Mar 20, 2026
d9f7830
fixing failing e2e
yoganandaness Mar 20, 2026
9afac60
fixing failed e2e
yoganandaness Mar 20, 2026
bba29a7
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 20, 2026
7df97cc
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Mar 20, 2026
671e3f6
ix: technique proposal table status handling
yoganandaness Mar 23, 2026
81107b6
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Mar 23, 2026
2b4d729
fix: show proposal ids
Mar 24, 2026
27d2c36
fix: clone proposal bug
Mar 24, 2026
4bdc221
refactor: update event handling in ProposalWorkflowEngine and Actor t…
Mar 26, 2026
c5a3324
fix: correct formatting of warning alert for status change to DRAFT
Mar 26, 2026
359a30e
refactor: streamline state transition tests and enhance guard handling
Mar 26, 2026
79a250f
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Mar 31, 2026
b7dc488
wip
yoganandaness Apr 1, 2026
3314913
refactor: rename workflow status connection tables for consistency
Apr 1, 2026
2d95a6d
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 1, 2026
ad9709d
fix: adding check to make sure the migration stops in case of invalid…
Apr 8, 2026
90609df
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 8, 2026
b308e2d
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Apr 12, 2026
dc0e490
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 12, 2026
6b8fe43
refactor: simplify instrument and technique insertion statements in S…
Apr 12, 2026
705b369
Merge branch 'SWAP-4949-workflow-overhaul' of https://github.com/User…
Apr 12, 2026
6d08628
Merge branch SWAP-4949-workflow-overhaul of github.com:UserOfficeProj…
yoganandaness Apr 14, 2026
8b5fa6b
fix: status action execution on manual proposal status change
yoganandaness Apr 14, 2026
4424b33
Merge branch 'SWAP-4949-workflow-overhaul' of github.com:UserOfficePr…
yoganandaness Apr 14, 2026
8fb3145
chore: Seggregating Proposal Entity workflow
yoganandaness Apr 15, 2026
69e5a02
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 20, 2026
ec0ae14
refactor: update patch name for clarity in RenameShortCodeToStatusId.sql
Apr 20, 2026
4cbaea5
refactor: update addStatusToWorkflow method to use AddStatusToWorkflo…
Apr 20, 2026
7cf294c
refactor: remove updateProposalWfStatus method and replace with chang…
Apr 20, 2026
a7105b3
refactor: streamline migration script by removing redundant pre-check…
Apr 20, 2026
89936ac
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 20, 2026
074279f
refactor: make workflow structure properties readonly for better immu…
Apr 20, 2026
8fc53f4
Merge branch 'SWAP-4949-workflow-overhaul' of https://github.com/User…
Apr 20, 2026
308c995
refactor: remove obsolete triggers and functions related to workflow …
Apr 21, 2026
638902f
fix: add getStatusByWorkflowStatusId method to StatusDataSource and i…
Apr 21, 2026
00a19c9
fix: remove status_id from proposals
Apr 21, 2026
1632bef
fix: fix tests
Apr 21, 2026
42fe3fd
feat: status action implemented for experiment safety
yoganandaness Apr 21, 2026
a890877
fix: fix seeds
Apr 22, 2026
89f0df6
fix: include reference to proposal_status
Apr 22, 2026
20f27a4
fix: remove status_id from ExperimentSafety and related data sources
Apr 22, 2026
4453450
fix: skip migration for experiment_safety as it no longer uses status_id
Apr 22, 2026
e2826bb
fix: simplify logic in UserAuthorization and FapQueries, streamline W…
Apr 22, 2026
81daaee
fix: initialize statusId as an empty string in createExperimentSafety…
Apr 22, 2026
a343a99
feat: manual status change of experiment safety implemented
yoganandaness Apr 23, 2026
f6b38cb
feat: Added logs to the Experiment
yoganandaness Apr 23, 2026
e24fb29
want to cfeat: Added logs to the Experiment
yoganandaness Apr 23, 2026
38fd5e5
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Apr 27, 2026
63b4247
fix: update guard names
Apr 27, 2026
d7a47d6
Merge branch 'SWAP-5222-user-office-experiment-workflow-improvement' …
yoganandaness Apr 28, 2026
f89279d
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Apr 29, 2026
9537ece
Merge branch 'SWAP-4949-workflow-overhaul' of github.com:UserOfficePr…
yoganandaness Apr 29, 2026
7b20e08
fix: only userofficer can use the experiment actions
yoganandaness Apr 29, 2026
267e6db
Merge develop and resolve conflicts
Copilot May 29, 2026
2b2f8fa
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 1, 2026
aaaf253
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 2, 2026
6da5832
fix: fix flaky tests
yoganandaness Jun 2, 2026
272e27f
feat: add guard function to check if experiment is rejected by instru…
yoganandaness Jun 3, 2026
ded5fa3
feat: add workflow status handling and implement experiment safety ch…
yoganandaness Jun 3, 2026
cc9f0cc
refactor: remove redundant feasibility status creation from instrumen…
yoganandaness Jun 3, 2026
5263707
refactor: remove unused proposal workflow handler and skip flaky test…
yoganandaness Jun 3, 2026
826be48
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 3, 2026
9f437d3
refactor: update workflow handler to skip exempted events and remove …
yoganandaness Jun 3, 2026
8ed2a73
refactor: reorganize state machine imports and remove simpleStateMach…
yoganandaness Jun 3, 2026
347b625
refactor: integrate proposal workflow into custom handler and export …
yoganandaness Jun 3, 2026
8e76ee6
refactor: remove experimentSafetyWorkflow handler and associated tests
yoganandaness Jun 3, 2026
9dde3b9
refactor: streamline experiment safety workflow handling and improve …
yoganandaness Jun 4, 2026
8a5d1db
refactor: replace string literal with StatusCode constant for exclude…
yoganandaness Jun 4, 2026
3db5539
refactor: undoing merge conflict resolving changes
yoganandaness Jun 4, 2026
951f241
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 4, 2026
795a1c4
Potential fix for pull request finding
yoganandaness Jun 4, 2026
a022a24
Potential fix for pull request finding
yoganandaness Jun 4, 2026
b307bb8
Potential fix for pull request finding
yoganandaness Jun 4, 2026
f7c4c35
Potential fix for pull request finding
yoganandaness Jun 4, 2026
56c041e
Fix docs: update rabbitMQActionHandler type from WorkflowEngineType[]…
Copilot Jun 4, 2026
f58c079
Potential fix for pull request finding
yoganandaness Jun 4, 2026
8a69a56
Potential fix for pull request finding
yoganandaness Jun 4, 2026
6164143
fix: use strict equality in ESI wizard status check
Copilot Jun 4, 2026
86e86e0
Fix ProposalDataSourceMock workflow status signature
Copilot Jun 4, 2026
48e1a08
feat: publish visit updated for approved visit registration updates a…
yoganandaness Jun 4, 2026
70b0789
chore: change favicon from ess to generic (#1550)
Copilot Jun 4, 2026
308a248
Merge develop and resolve proposal seed conflict
Copilot Jun 4, 2026
59c159e
Merge origin/develop into SWAP-5222-user-office-experiment-workflow-i…
Copilot Jun 4, 2026
51e5c74
Merge remote branch updates and resolve seed SQL conflict
Copilot Jun 4, 2026
e981380
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 4, 2026
1d54a84
fix: correct column order in instrument_has_proposals and questionari…
yoganandaness Jun 8, 2026
0141550
feat: implement experiment safety review workflow improvements and UI…
yoganandaness Jun 8, 2026
db70b5d
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 8, 2026
43c8c5f
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 9, 2026
369cff4
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 15, 2026
046add4
refactor: clean up unused dummyProposalEvents and improve rejection h…
yoganandaness Jun 19, 2026
ef1c386
feat: enhance experiment safety workflow with new status codes and im…
yoganandaness Jun 19, 2026
1f2bcf2
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
yoganandaness Jun 19, 2026
06ba852
Merge branch 'SWAP-5222-user-office-experiment-workflow-improvement' …
yoganandaness Jun 19, 2026
1b508b6
fix: correct spelling of ESF_APPROVED in ExperimentSafetyWorkflowStat…
yoganandaness Jul 1, 2026
225f2e5
Merge branch 'develop' into SWAP-5222-user-office-experiment-workflow…
jekabs-karklins Jul 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
DO
$$
DECLARE
exp_safety_review_template_id_var int;
BEGIN
IF register_patch(
'ActivateExperimentSafetyReviewTemplate.sql',
'Yoganandan Pandiyan',
'Mark an experiment safety review template as active when none is active.',
'2026-06-08'
) THEN

SELECT template_id
INTO exp_safety_review_template_id_var
FROM templates
WHERE group_id = 'EXPERIMENT_SAFETY_REVIEW_TEMPLATE'
AND NOT EXISTS (
SELECT 1
FROM active_templates
WHERE group_id = 'EXPERIMENT_SAFETY_REVIEW_TEMPLATE'
)
ORDER BY template_id
LIMIT 1;

IF exp_safety_review_template_id_var IS NOT NULL THEN
INSERT INTO active_templates(group_id, template_id)
VALUES (
'EXPERIMENT_SAFETY_REVIEW_TEMPLATE',
exp_safety_review_template_id_var
)
ON CONFLICT (group_id) DO NOTHING;
END IF;

END IF;
END;
$$
LANGUAGE plpgsql;
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ BEGIN
, comment_for_management
, comment_for_user
, notified
, management_decision_submitted
, management_decision_submitted
, submitted
)
VALUES
Expand All @@ -98,11 +98,11 @@ BEGIN
, NULL
, NULL
, true
, true
, true
, true
, true
);

INSERT INTO instrument_has_proposals(instrument_id, proposal_pk) VALUES (1, 1);
INSERT INTO instrument_has_proposals(instrument_id, proposal_pk, management_time_allocation) VALUES (1, 1, 100);

INSERT INTO technical_review(proposal_pk, comment, time_allocation, status, public_comment, reviewer_id, technical_review_assignee_id, instrument_id, questionary_id)
VALUES (1, '', 2, 0, '', 0, 0, 1, technical_review_questionary_id_var);
Expand All @@ -122,7 +122,7 @@ BEGIN
, comment_for_management
, comment_for_user
, notified
, management_decision_submitted
, management_decision_submitted
, submitted
)
VALUES
Expand All @@ -140,11 +140,11 @@ BEGIN
, NULL
, NULL
, true
, true
, true
, true
, true
);

INSERT INTO instrument_has_proposals(instrument_id, proposal_pk) VALUES (2, 2);
INSERT INTO instrument_has_proposals(instrument_id, proposal_pk, management_time_allocation) VALUES (2, 2, 100);

END;
$DO$
Expand Down
285 changes: 283 additions & 2 deletions apps/backend/db_patches/db_seeds/0004_Experiments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ DECLARE
instrument_id_1_var int;
instrument_id_2_var int;
experiment_workflow_id_var int;
awaiting_esf_workflow_status_id_var int;
esf_is_review_workflow_status_id_var int;
esf_esr_review_workflow_status_id_var int;
esf_approved_workflow_status_id_var int;
esf_rejected_workflow_status_id_var int;
workflow_status_connection_id_var int;
email_action_id_var int;
rabbitmq_action_id_var int;
BEGIN
-- Get instrument ids
SELECT instrument_id INTO instrument_id_1_var FROM instruments WHERE name='Instrument 1' limit 1;
Expand All @@ -18,8 +26,277 @@ DECLARE

UPDATE call SET experiment_workflow_id = experiment_workflow_id_var;

INSERT INTO workflow_has_statuses(workflow_id, status_id)
VALUES (experiment_workflow_id_var, (SELECT status_id FROM statuses WHERE status_id='AWAITING_ESF'));
SELECT workflow_status_action_id
INTO email_action_id_var
FROM workflow_status_actions
WHERE type = 'EMAIL'
LIMIT 1;

SELECT workflow_status_action_id
INTO rabbitmq_action_id_var
FROM workflow_status_actions
WHERE type = 'RABBITMQ'
LIMIT 1;

INSERT INTO workflow_has_statuses(workflow_id, status_id, pos_x, pos_y)
VALUES (experiment_workflow_id_var, 'AWAITING_ESF', -191, -117)
RETURNING workflow_status_id INTO awaiting_esf_workflow_status_id_var;

INSERT INTO workflow_has_statuses(workflow_id, status_id, pos_x, pos_y)
VALUES (experiment_workflow_id_var, 'ESF_IS_REVIEW', -190, 5)
RETURNING workflow_status_id INTO esf_is_review_workflow_status_id_var;

INSERT INTO workflow_has_statuses(workflow_id, status_id, pos_x, pos_y)
VALUES (experiment_workflow_id_var, 'ESF_ESR_REVIEW', -189, 189)
RETURNING workflow_status_id INTO esf_esr_review_workflow_status_id_var;

INSERT INTO workflow_has_statuses(workflow_id, status_id, pos_x, pos_y)
VALUES (experiment_workflow_id_var, 'ESF_APPROVED', 303, 135)
RETURNING workflow_status_id INTO esf_approved_workflow_status_id_var;

INSERT INTO workflow_has_statuses(workflow_id, status_id, pos_x, pos_y)
VALUES (experiment_workflow_id_var, 'ESF_REJECTED', -187, 361)
RETURNING workflow_status_id INTO esf_rejected_workflow_status_id_var;

INSERT INTO workflow_status_connections(
workflow_id,
prev_workflow_status_id,
next_workflow_status_id,
source_handle,
target_handle
)
VALUES (
experiment_workflow_id_var,
awaiting_esf_workflow_status_id_var,
esf_is_review_workflow_status_id_var,
'bottom-source',
'top-target'
)
RETURNING workflow_status_connection_id INTO workflow_status_connection_id_var;

INSERT INTO workflow_status_connection_has_events(
workflow_status_connection_id,
status_changing_event
)
VALUES (workflow_status_connection_id_var, 'EXPERIMENT_ESF_SUBMITTED');

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
email_action_id_var,
experiment_workflow_id_var,
'{"recipientsWithEmailTemplate":[{"recipient":{"name":"INSTRUMENT_SCIENTISTS","description":"Instrument scientists including the manager on the instrument related to the proposal"},"emailTemplate":{"id":"instrument-scientist-esf-review","name":"Instrument Scientist ESF Review"}}]}'
);

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
rabbitmq_action_id_var,
experiment_workflow_id_var,
'{"exchanges":["user_office_backend.fanout"]}'
);

INSERT INTO workflow_status_connections(
workflow_id,
prev_workflow_status_id,
next_workflow_status_id,
source_handle,
target_handle
)
VALUES (
experiment_workflow_id_var,
esf_is_review_workflow_status_id_var,
esf_approved_workflow_status_id_var,
'right-source',
'top-target'
)
RETURNING workflow_status_connection_id INTO workflow_status_connection_id_var;

INSERT INTO workflow_status_connection_has_events(
workflow_status_connection_id,
status_changing_event
)
VALUES (workflow_status_connection_id_var, 'EXPERIMENT_ESF_APPROVED_BY_IS');

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
email_action_id_var,
experiment_workflow_id_var,
'{"recipientsWithEmailTemplate":[{"recipient":{"name":"PI","description":"Principal investigator on the proposal"},"emailTemplate":{"id":"esf-approved","name":"ESF Approved"}}]}'
);

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
rabbitmq_action_id_var,
experiment_workflow_id_var,
'{"exchanges":["user_office_backend.fanout"]}'
);

INSERT INTO workflow_status_connections(
workflow_id,
prev_workflow_status_id,
next_workflow_status_id,
source_handle,
target_handle
)
VALUES (
experiment_workflow_id_var,
esf_esr_review_workflow_status_id_var,
esf_rejected_workflow_status_id_var,
'bottom-source',
'top-target'
)
RETURNING workflow_status_connection_id INTO workflow_status_connection_id_var;

INSERT INTO workflow_status_connection_has_events(
workflow_status_connection_id,
status_changing_event
)
VALUES (workflow_status_connection_id_var, 'EXPERIMENT_ESF_REJECTED_BY_ESR');

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
email_action_id_var,
experiment_workflow_id_var,
'{"recipientsWithEmailTemplate":[{"recipient":{"name":"PI","description":"Principal investigator on the proposal"},"emailTemplate":{"id":"esf-rejected","name":"ESF Rejected"}}]}'
);

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
rabbitmq_action_id_var,
experiment_workflow_id_var,
'{"exchanges":["user_office_backend.fanout"]}'
);

INSERT INTO workflow_status_connections(
workflow_id,
prev_workflow_status_id,
next_workflow_status_id,
source_handle,
target_handle
)
VALUES (
experiment_workflow_id_var,
esf_is_review_workflow_status_id_var,
esf_esr_review_workflow_status_id_var,
'bottom-source',
'top-target'
)
RETURNING workflow_status_connection_id INTO workflow_status_connection_id_var;

INSERT INTO workflow_status_connection_has_events(
workflow_status_connection_id,
status_changing_event
)
VALUES (workflow_status_connection_id_var, 'EXPERIMENT_ESF_REJECTED_BY_IS');

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
email_action_id_var,
experiment_workflow_id_var,
'{"recipientsWithEmailTemplate":[{"recipient":{"name":"EXPERIMENT_SAFETY_REVIEWERS","description":"The Experiment Safety email address"},"emailTemplate":{"id":"esr-esf-review","name":"ESR ESF Review"}}]}'
);

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
rabbitmq_action_id_var,
experiment_workflow_id_var,
'{"exchanges":["user_office_backend.fanout"]}'
);

INSERT INTO workflow_status_connections(
workflow_id,
prev_workflow_status_id,
next_workflow_status_id,
source_handle,
target_handle
)
VALUES (
experiment_workflow_id_var,
esf_esr_review_workflow_status_id_var,
esf_is_review_workflow_status_id_var,
'right-source',
'right-target'
)
RETURNING workflow_status_connection_id INTO workflow_status_connection_id_var;

INSERT INTO workflow_status_connection_has_events(
workflow_status_connection_id,
status_changing_event
)
VALUES (workflow_status_connection_id_var, 'EXPERIMENT_ESF_APPROVED_BY_ESR');

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
email_action_id_var,
experiment_workflow_id_var,
'{"recipientsWithEmailTemplate":[{"recipient":{"name":"INSTRUMENT_SCIENTISTS","description":"Instrument scientists including the manager on the instrument related to the proposal"},"combineEmails":null,"emailTemplate":{"id":"instrument-scientist-esf-review","name":"Instrument Scientist ESF Review"},"otherRecipientEmails":null}]}'
);

INSERT INTO workflow_status_connection_has_actions(
workflow_status_connection_id,
workflow_status_action_id,
workflow_id,
config
)
VALUES (
workflow_status_connection_id_var,
rabbitmq_action_id_var,
experiment_workflow_id_var,
'{"exchanges":["user_office_backend.fanout"]}'
);

INSERT INTO experiments(
experiment_pk, experiment_id, scheduled_event_id, starts_at, ends_at, proposal_pk, status, local_contact_id, instrument_id)
Expand Down Expand Up @@ -47,6 +324,10 @@ DECLARE
INTO exp_safety_review_template_id_var
from templates
where group_id = 'EXPERIMENT_SAFETY_REVIEW_TEMPLATE' limit 1;

INSERT INTO active_templates(group_id, template_id)
VALUES ('EXPERIMENT_SAFETY_REVIEW_TEMPLATE', exp_safety_review_template_id_var)
ON CONFLICT (group_id) DO NOTHING;

select topics.topic_id
INTO exp_safety_review_template_topic_id_var
Expand Down
Loading
Loading