Skip to content

feat: introduce experiment created and updated events#1342

Open
yoganandaness wants to merge 8 commits intodevelopfrom
SWAP-4987-user-office-experiments-connector-message-to-scic
Open

feat: introduce experiment created and updated events#1342
yoganandaness wants to merge 8 commits intodevelopfrom
SWAP-4987-user-office-experiments-connector-message-to-scic

Conversation

@yoganandaness
Copy link
Contributor

@yoganandaness yoganandaness commented Feb 9, 2026

Description

This pull request introduces significant improvements to the backend's event handling and message brokering, especially around experiments and proposals. The main changes include implementing a new function to generate comprehensive experiment message data (including related samples, proposal, and instrument information), updating the RabbitMQ message broker to handle new experiment-related events, and enhancing mock data sources and tests to support these features.

Motivation and Context

Experiment event support and messaging

How Has This Been Tested

Attached Unit tests

Fixes

Changes

Enhancements to message brokering and event handling:

  • Added a new getExperimentMessageData function in messageBroker.ts to construct detailed JSON messages for experiments, including associated samples, proposal, and instrument data.
  • Updated the RabbitMQ event handler to publish messages for EXPERIMENT_CREATED, EXPERIMENT_UPDATED, and EXPERIMENT_ESF_SUBMITTED events using the new experiment message data structure.
  • Improved proposal message data to include associated samples, and ensured proposals must exist before sending messages.

Testing improvements:

  • Added comprehensive tests for getExperimentMessageData to verify inclusion of instrument, samples, and proposer data, and to handle missing instruments.
  • Introduced a new test suite for the experiment safety workflow event handler, covering edge cases and status change event publishing.

Depends on

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

…osal and experiment messages with sample data.
@yoganandaness yoganandaness requested a review from a team as a code owner February 9, 2026 10:07
@yoganandaness yoganandaness requested review from TCMeldrum and removed request for a team February 9, 2026 10:07
@yoganandaness yoganandaness force-pushed the SWAP-4987-user-office-experiments-connector-message-to-scic branch from 2363855 to f5d8335 Compare February 10, 2026 14:18
@yoganandaness yoganandaness changed the title feat: Introduce experiment created and updated events, enhancing prop… feat: introduce experiment created and updated events Feb 10, 2026
… creation/update events to the message broker.
@yoganandaness yoganandaness force-pushed the SWAP-4987-user-office-experiments-connector-message-to-scic branch from 3f83c1b to 990dfa2 Compare February 13, 2026 12:52
shortCode: string;
title: string;
submitted: boolean;
samples?: { id: number; title: string }[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Can we do a simple Pick<Sample, 'id' | 'title'> here. This would help if anyone refactors in the future

endsAt: Date;
status: string;
proposal?: ProposalMessageData;
samples?: { id: number; title: string }[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: ditto

await sampleDataSource.getSamples({
filter: { proposalPk: proposal.primaryKey },
})
).map((sample) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: ditto

Copy link
Contributor

@jekabs-karklins jekabs-karklins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants