Refactor of monster to use the platform infrastructure (BaseDomain, BaseNodeAdapter, ChildRouter, commandRegistry, statusBadge). Extracts concerns into focused modules per .claude/refactor/MODULE_SPLIT.md generic template. Tests stay green; CONTRACT.md generated; legacy aliases preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
// AQUON sample schedule helpers. updateMonsternametijden validates the
|
|
// row shape before storing; regNextDate walks the rows to find the next
|
|
// future START_DATE for the configured aquonSampleName and counts how
|
|
// many of those fall in the current calendar year.
|
|
|
|
function updateMonsternametijden(m, value) {
|
|
if (!m.init || !value || Object.keys(value).length === 0) return;
|
|
if (
|
|
typeof value[0]?.SAMPLE_NAME !== 'undefined' &&
|
|
typeof value[0]?.DESCRIPTION !== 'undefined' &&
|
|
typeof value[0]?.SAMPLED_DATE !== 'undefined' &&
|
|
typeof value[0]?.START_DATE !== 'undefined' &&
|
|
typeof value[0]?.END_DATE !== 'undefined'
|
|
) {
|
|
m.monsternametijden = value;
|
|
regNextDate(m, value);
|
|
}
|
|
}
|
|
|
|
function regNextDate(m, monsternametijden) {
|
|
let next_date = new Date(new Date().setFullYear(new Date().getFullYear() + 1));
|
|
let n_days_remaining = 0;
|
|
|
|
if (typeof monsternametijden !== 'undefined') {
|
|
Object.values(monsternametijden).forEach((line) => {
|
|
if (line.START_DATE === 'NULL') return;
|
|
const curr_date_conv = new Date(line.START_DATE);
|
|
const curr_date = curr_date_conv.getTime();
|
|
if (line.SAMPLE_NAME === m.aquonSampleName && curr_date > Date.now()) {
|
|
if (curr_date < next_date) next_date = curr_date;
|
|
if (new Date().getFullYear() === curr_date_conv.getFullYear()) n_days_remaining++;
|
|
}
|
|
});
|
|
}
|
|
|
|
m.daysPerYear = n_days_remaining;
|
|
m.nextDate = next_date;
|
|
}
|
|
|
|
module.exports = { updateMonsternametijden, regNextDate };
|