Skip to content

Commit bb80c29

Browse files
authored
Fixed retrieval of latest available QO (#2081)
1 parent 64fa7f1 commit bb80c29

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

Modules/Common/src/BigScreen.cxx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "QualityControl/MonitorObject.h"
2121
#include "QualityControl/DatabaseInterface.h"
2222
#include "QualityControl/ObjectMetadataKeys.h"
23+
#include "QualityControl/ActivityHelpers.h"
2324
#include <TDatime.h>
2425
#include <TPaveText.h>
2526
#include <chrono>
@@ -105,19 +106,27 @@ void BigScreen::initialize(quality_control::postprocessing::Trigger t, framework
105106

106107
static std::pair<std::shared_ptr<QualityObject>, bool> getQO(repository::DatabaseInterface& qcdb, Trigger t, BigScreenConfig::DataSource& source, long notOlderThan, bool ignoreActivity)
107108
{
108-
// retrieve MO from CCDB - do not associate to trigger activity if ignoreActivity is true
109-
auto qo = ignoreActivity ? qcdb.retrieveQO(source.path, t.timestamp, {}) : qcdb.retrieveQO(source.path, t.timestamp, t.activity);
110-
if (!qo) {
109+
// find the time-stamp of the most recent object matching the current activity
110+
// if ignoreActivity is true the activity matching criteria are not applied
111+
Activity activity = ignoreActivity ? Activity{} : t.activity;
112+
auto timestamp = t.timestamp;
113+
const auto objFullPath = t.activity.mProvenance + "/" + source.path;
114+
const auto filterMetadata = activity_helpers::asDatabaseMetadata(activity, false);
115+
const auto objectValidity = qcdb.getLatestObjectValidity(objFullPath, filterMetadata);
116+
if (objectValidity.isValid()) {
117+
timestamp = objectValidity.getMax() - 1;
118+
} else {
119+
ILOG(Warning, Devel) << "Could not find an object '" << objFullPath << "' for activity " << activity << ENDM;
111120
return { nullptr, false };
112121
}
113-
// get the MO creation time stamp
114-
long timeStamp{ 0 };
115-
auto iter = qo->getMetadataMap().find(repository::metadata_keys::created);
116-
if (iter != qo->getMetadataMap().end()) {
117-
timeStamp = std::stol(iter->second);
122+
123+
// retrieve QO from CCDB - do not associate to trigger activity if ignoreActivity is true
124+
auto qo = qcdb.retrieveQO(source.path, timestamp, activity);
125+
if (!qo) {
126+
return { nullptr, false };
118127
}
119128

120-
long elapsed = static_cast<long>(t.timestamp) - timeStamp;
129+
long elapsed = static_cast<long>(t.timestamp) - timestamp;
121130
// check if the object is not older than a given number of milliseconds
122131
if (elapsed > notOlderThan) {
123132
return { qo, false };

0 commit comments

Comments
 (0)