Skip to content

Show a selector for initial duration at job launch - #721

Merged
ianmcorvidae merged 3 commits into
cyverse-de:mainfrom
ianmcorvidae:initial-duration
Aug 6, 2026
Merged

Show a selector for initial duration at job launch#721
ianmcorvidae merged 3 commits into
cyverse-de:mainfrom
ianmcorvidae:initial-duration

Conversation

@ianmcorvidae

Copy link
Copy Markdown
Member

(defaulting to pre-existing calculation method)

depends on cyverse-de/timelord#31 cyverse-de/common-swagger-api#100 cyverse-de/apps#302

This is the one of this batch I'm least sure of, but I think it should be alright. The calculation of the dropdown options is a bit funky though, and hopefully the field shows at the correct times (or not).

@psarando psarando left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍
I just had some questions and minor comments.

Comment on lines +312 to +313
const SECONDS_PER_HOUR = 3600;
const SECONDS_PER_DAY = 86400;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I personally prefer the less-ambiguous raw calculations over the results (60 * 60 and 60 * 60 * 24).
I once read an article that gave a metric of how common the constant 84600 was across github 😅
But not necessary to update this here.

Comment on lines +304 to +306
const SECONDS_PER_MINUTE = 60;
const SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
const SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment thread src/components/apps/launch/formatters.js Outdated
Comment thread src/__tests__/apps/launch.js Outdated
Comment thread src/__tests__/apps/launch.js Outdated
Comment on lines +349 to +365
/**
* Formats a duration given in seconds as a human-readable string.
*
* @param {number} seconds - The duration in seconds.
* @returns {string} - The formatted duration (e.g. "12 hours", "3 days").
*/
const formatDuration = (seconds) => {
if (!seconds) {
return "";
}
const days = Math.floor(seconds / SECONDS_PER_DAY);
seconds %= SECONDS_PER_DAY;
const hours = Math.floor(seconds / SECONDS_PER_HOUR);
seconds %= SECONDS_PER_HOUR;
const minutes = Math.floor(seconds / SECONDS_PER_MINUTE);
return formatDurationStr({ days, hours, minutes });
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice 👍
Eventually, if anything else needs to use this function, it could move into components/utils/DateFormatter, but that's not necessary now.

Comment thread src/components/apps/launch/AnalysisInfoForm.js Outdated
*/
function InitialDurationField({ baseId, maxTimeLimitSeconds }) {
const { t } = useTranslation("launch");
const { values } = useFormikContext();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I keep forgetting about useFormikContext 👍

@ianmcorvidae

Copy link
Copy Markdown
Member Author

Thanks for the review! I'll go ahead and merge this since I think I've mopped up the remaining issues of my own comprehension. If you have more thoughts we can still make changes of course.

@ianmcorvidae
ianmcorvidae merged commit 98e0042 into cyverse-de:main Aug 6, 2026
2 of 3 checks passed
@psarando

psarando commented Aug 6, 2026

Copy link
Copy Markdown
Member

LGTM 👍 🎉

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.

2 participants