Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions lib/database/repositories/QcFlagRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,17 @@ class QcFlagRepository extends Repository {
GROUP_CONCAT(effectivePeriods.flagsList) AS flagsList,

IF(
(
COALESCE(run.time_trg_end, run.time_o2_end ) IS NULL
OR COALESCE(run.time_trg_start, run.time_o2_start) IS NULL
),
run.time_start IS NULL OR run.time_end IS NULL,
IF(
SUM(
COALESCE(effectivePeriods.\`to\` , 0)
+ COALESCE(effectivePeriods.\`from\`, 0)
) = 0,
effectivePeriods.\`from\` IS NULL AND effectivePeriods.\`to\` IS NULL,
1,
null
),
SUM(
COALESCE(
effectivePeriods.\`to\`,
UNIX_TIMESTAMP(run.time_trg_end),
UNIX_TIMESTAMP(run.time_o2_end)
)
- COALESCE(
effectivePeriods.\`from\`,
UNIX_TIMESTAMP(run.time_trg_start),
UNIX_TIMESTAMP(run.time_o2_start)
)
COALESCE(effectivePeriods.\`to\`, UNIX_TIMESTAMP(run.time_end))
- COALESCE(effectivePeriods.\`from\`, UNIX_TIMESTAMP(run.time_start))
) / (
UNIX_TIMESTAMP(COALESCE(run.time_trg_end, run.time_o2_end))
- UNIX_TIMESTAMP(COALESCE(run.time_trg_start, run.time_o2_start))
UNIX_TIMESTAMP(run.time_end) - UNIX_TIMESTAMP(run.time_start)
)
) AS effectiveRunCoverage

Expand Down
27 changes: 6 additions & 21 deletions lib/server/services/qualityControlFlag/QcFlagService.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,35 +264,20 @@ class QcFlagService {
[
sequelize.literal(`
IF(
(
COALESCE(run.time_trg_end, run.time_o2_end ) IS NULL
OR COALESCE(run.time_trg_start, run.time_o2_start) IS NULL
),
run.time_start IS NULL OR run.time_end IS NULL,
IF(
SUM(
COALESCE(UNIX_TIMESTAMP(effectivePeriods.\`to\` ), 0)
+ COALESCE(UNIX_TIMESTAMP(effectivePeriods.\`from\`), 0)
) = 0,
effectivePeriods.\`from\` IS NULL AND effectivePeriods.\`to\` IS NULL,
1,
null
),
SUM(
UNIX_TIMESTAMP(COALESCE(
effectivePeriods.\`to\`,
run.time_trg_end,
run.time_o2_end
))
- UNIX_TIMESTAMP(COALESCE(
effectivePeriods.\`from\`,
run.time_trg_start,
run.time_o2_start
))
UNIX_TIMESTAMP(COALESCE(effectivePeriods.\`to\`, run.time_end))
- UNIX_TIMESTAMP(COALESCE(effectivePeriods.\`from\`, run.time_start))
) / (
UNIX_TIMESTAMP(COALESCE(run.time_trg_end, run.time_o2_end))
- UNIX_TIMESTAMP(COALESCE(run.time_trg_start, run.time_o2_start))
UNIX_TIMESTAMP(run.time_end) - UNIX_TIMESTAMP(run.time_start)
)
)
`),
`),
'effectiveRunCoverage',
],
[
Expand Down
6 changes: 3 additions & 3 deletions lib/server/services/run/setO2StopOfLostRuns.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ exports.setO2StopOfLostRuns = async (runNumbersOfRunningRuns, modificationTimePe
FROM runs
WHERE time_o2_end IS NULL
AND time_trg_end IS NULL
AND COALESCE(time_trg_start, time_o2_start) IS NOT NULL
AND COALESCE(time_trg_start, time_o2_start) >= '${timestampToMysql(modificationTimePeriod.from, true)}'
AND COALESCE(time_trg_start, time_o2_start) < '${timestampToMysql(modificationTimePeriod.to, true)}'
AND time_start IS NOT NULL
AND time_start >= '${timestampToMysql(modificationTimePeriod.from, true)}'
AND time_start < '${timestampToMysql(modificationTimePeriod.to, true)}'
`;
if (runNumbersOfRunningRuns.length > 0) {
fetchQuery += ` AND run_number NOT IN (${runNumbersOfRunningRuns.join(',')})`;
Expand Down
Loading