Skip to content

feat: add allocation time unit to instrument picker question - #1681

Draft
joeshannon wants to merge 1 commit into
developfrom
1629-instrument-picker-time-units
Draft

feat: add allocation time unit to instrument picker question#1681
joeshannon wants to merge 1 commit into
developfrom
1629-instrument-picker-time-units

Conversation

@joeshannon

@joeshannon joeshannon commented Jul 27, 2026

Copy link
Copy Markdown

Description

Motivation and Context

How Has This Been Tested

Fixes

This fixes UserOfficeProject/issue-tracker#1629

Changes

Before:
619480665-ebb885fb-e920-4f6c-83d4-936b7bdee45a

After:
Screenshot From 2026-07-27 17-18-45

Depends on

Tests included/Docs Updated?

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

@joeshannon
joeshannon force-pushed the 1629-instrument-picker-time-units branch from eee6cd4 to 7600f40 Compare July 27, 2026 16:14
@joeshannon
joeshannon force-pushed the 1629-instrument-picker-time-units branch from 7600f40 to 89ce084 Compare July 27, 2026 16:16
);
const call = await callDataSource.getCall(callId);
if (!call) {
throw new Error('Call not found');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see this is in a try block, but if the try fails then it just errors out. Maybe we'd rather go back to fallBackConfig, if we can't get the call? or still show the instrument picker on screen, just without a allocatedTimeUnit?

@zacharyjhankin

Copy link
Copy Markdown
Collaborator

I am a bit confused why we actually need to store the allocationTimeUnit as a config with the question type. As one question could be used for multiple different calls, so could have multiple different allocationTimeUnits that we need to show to users.

Surely it would make more sense to generate the allocationTimeUnit that is relevant to the user purely in the frontend by calling a graphQL query and fill in the string at that point in time. Then you wouldn't need to edit the config and put the value in there.

What we are risking by putting the allocationTimeUnit in the database here, is that the value in the database is wrong. So we need to verify that it is correct at runtime when the user loads the screen. At that point we wouldn't need it in the database anyway

@joeshannon

Copy link
Copy Markdown
Author

I am a bit confused why we actually need to store the allocationTimeUnit as a config with the question type. As one question could be used for multiple different calls, so could have multiple different allocationTimeUnits that we need to show to users.

Surely it would make more sense to generate the allocationTimeUnit that is relevant to the user purely in the frontend by calling a graphQL query and fill in the string at that point in time. Then you wouldn't need to edit the config and put the value in there.

What we are risking by putting the allocationTimeUnit in the database here, is that the value in the database is wrong. So we need to verify that it is correct at runtime when the user loads the screen. At that point we wouldn't need it in the database anyway

Note that modifications made by transformConfig do not get stored in the database:

  /**
   * Function to transform the config value before sending back to the front end.
   * Ideal for changes in config at run time.
   */
  readonly transformConfig?: (
    config: QuestionDataTypeConfigMapping<T>,
    callId?: number
  ) => Promise<QuestionDataTypeConfigMapping<T>>;

I've used the same approach as is used for the instruments in the picker where the available instruments are dynamically set based on the call.

I agree with your comment in general, although I'm not sure what an alternative solution would look like. The complication arises due to the fact that a question doesn't directly have a relation to a specific call. Once there is an answer associated (i.e. the user presses save) it is possible - this is actually already implemented for InstrumentPickerAnswerRenderer. However it's entirely possible I've missed an alternative approach!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add call time unit to instrument picker

2 participants