Skip to content

feat: shift as an option for allocation time period#1563

Open
zacharyjhankin wants to merge 6 commits into
developfrom
UAS-14525-time-unit
Open

feat: shift as an option for allocation time period#1563
zacharyjhankin wants to merge 6 commits into
developfrom
UAS-14525-time-unit

Conversation

@zacharyjhankin

@zacharyjhankin zacharyjhankin commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR adds a shift as a new unit for calls. This ability is vital for diamond as we allocate beam time from the synchrotron based on 8 hour units, 3 per day. All existing proposals base the scientists requests for beam time in shift units, so this allows us to be consistent with the existing infrastructure. It also prevents requests for 3 hours.

The way I have coded this allows other organisations to customise the shift unit to be any length of time they want. So it could be useful to them.

Motivation and Context

At diamond we use shift as a time unit for our calls which is 8 hours. This PR allows us to have shifts and lets other companies edit it.

How Has This Been Tested

image image I set the time period to shift, then edited the code to execute getProposalMessageData when a proposal is submitted. Then verified that it correctly calculates the time. from the shift time period as you can see above. I manually set the allocated time to 1 so it multiplies 1 by the shift time in seconds. This is actually the only place in code that references how long an allocation period is in reality.

Changes

A new allocation period unit.

Tests included/Docs Updated?

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

@zacharyjhankin zacharyjhankin changed the title add custom unit shift add: shift as an option for allocation time period Jun 10, 2026
@zacharyjhankin zacharyjhankin changed the title add: shift as an option for allocation time period feat: shift as an option for allocation time period Jun 12, 2026
@zacharyjhankin zacharyjhankin marked this pull request as ready for review June 15, 2026 10:22
@zacharyjhankin zacharyjhankin requested a review from a team as a code owner June 15, 2026 10:22
@zacharyjhankin zacharyjhankin requested review from mutambaraf and removed request for a team June 15, 2026 10:22

@jekabs-karklins jekabs-karklins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just some minor comments

unit: AllocationTimeUnits
) => number;

export const getSecondsFromAllocationTimeUnits: AllocationTimeUnitConverter = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: maybe it is a good idea to call the filename the same as the exported function

) => {
// NOTE: Default AllocationTimeUnit is 'Day'.
// 'Shift' is configurable per organisation; it defaults to 8 hours here.
switch (unit) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: adding a quick unit test would be nice

return timeAllocation * 7 * 24 * 60 * 60;
case AllocationTimeUnits.Shift:
return timeAllocation * 60 * 60 * 8;
default:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
default:
case AllocationTimeUnits.Day:
default:

Can we have this? so it's more intutitve by looking at the code what is the default?

unit: AllocationTimeUnits
) => {
// NOTE: Default AllocationTimeUnit is 'Day'.
// 'Shift' is configurable per organisation; it defaults to 8 hours here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 'Shift' is configurable per organisation; it defaults to 8 hours here.
// NOTE: Shift duration defaults to 8 hours.
// To customize this per organization, inject a configuration provider
// that supplies the specific shift duration for the facility.

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.

3 participants