Skip to content

Commit 35535be

Browse files
committed
Set Activity in Check Runner again (#1830)
this rolls back the changes of the commit below without having to revert a lot of intertwined commits. 82be5ff we need to think how aggregators should behave in the new scenario for a proper fix
1 parent bed81d1 commit 35535be

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

Framework/include/QualityControl/CheckRunner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ class CheckRunner : public framework::Task
150150
*
151151
* @param qualityObjects QOs to be stored in DB.
152152
*/
153-
void store(QualityObjectsType& qualityObjects);
153+
void store(QualityObjectsType& qualityObjects, long validFrom);
154154

155155
/**
156156
* \brief Store the MonitorObjects in the database.
157157
*
158158
* @param monitorObjects MOs to be stored in DB.
159159
*/
160-
void store(std::vector<std::shared_ptr<MonitorObject>>& monitorObjects);
160+
void store(std::vector<std::shared_ptr<MonitorObject>>& monitorObjects, long validFrom);
161161

162162
/**
163163
* \brief Send the QualityObjects on the DataProcessor output channel.

Framework/src/CcdbDatabase.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,13 @@ void CcdbDatabase::storeMO(std::shared_ptr<const o2::quality_control::core::Moni
238238
auto from = static_cast<long>(validity.getMin());
239239
auto to = static_cast<long>(validity.getMax());
240240

241-
if (from == -1 || validity.getMin() == gInvalidValidityInterval.getMin()) {
241+
if (from == -1 || from == 0 || validity.getMin() == gInvalidValidityInterval.getMin() || validity.getMin() == gFullValidityInterval.getMin()) {
242242
from = getCurrentTimestamp();
243243
}
244-
if (to == -1 || validity.getMax() == gInvalidValidityInterval.getMax()) {
244+
if (to == -1 || to == 0 || validity.getMax() == gInvalidValidityInterval.getMax() || validity.getMax() == gFullValidityInterval.getMax()) {
245245
to = from + 1000l * 60 * 60 * 24 * 365 * 10; // ~10 years since the start of validity
246246
}
247+
247248
if (from >= to) {
248249
ILOG(Error, Support) << "The start validity of '" << mo->GetName() << "' is not earlier than the end (" << from << ", " << to << "). The object will not be stored" << ENDM;
249250
return;
@@ -279,10 +280,10 @@ void CcdbDatabase::storeQO(std::shared_ptr<const o2::quality_control::core::Qual
279280
auto from = static_cast<long>(validity.getMin());
280281
auto to = static_cast<long>(validity.getMax());
281282

282-
if (from == -1 || validity.getMin() == gInvalidValidityInterval.getMin()) {
283+
if (from == -1 || from == 0 || validity.getMin() == gInvalidValidityInterval.getMin() || validity.getMin() == gFullValidityInterval.getMin()) {
283284
from = getCurrentTimestamp();
284285
}
285-
if (to == -1 || validity.getMax() == gInvalidValidityInterval.getMax()) {
286+
if (to == -1 || to == 0 || validity.getMax() == gInvalidValidityInterval.getMax() || validity.getMax() == gFullValidityInterval.getMax()) {
286287
to = from + 1000l * 60 * 60 * 24 * 365 * 10; // ~10 years since the start of validity
287288
}
288289
if (from >= to) {

Framework/src/CheckRunner.cxx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,27 @@ void CheckRunner::init(framework::InitContext& iCtx)
240240
}
241241
}
242242

243+
long getCurrentTimestamp()
244+
{
245+
auto now = std::chrono::system_clock::now();
246+
auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(now);
247+
auto epoch = now_ms.time_since_epoch();
248+
auto value = std::chrono::duration_cast<std::chrono::milliseconds>(epoch);
249+
return value.count();
250+
}
251+
243252
void CheckRunner::run(framework::ProcessingContext& ctx)
244253
{
245254
prepareCacheData(ctx.inputs());
246255

247256
auto qualityObjects = check();
248257

249-
store(qualityObjects);
250-
store(mMonitorObjectStoreVector);
258+
// we want all objects that we are going to store to have the same validFrom values.
259+
// ideally it should be SOR or the moving window start, but before GUI allows for this,
260+
// we have to put the current timestamp.
261+
auto now = getCurrentTimestamp();
262+
store(qualityObjects, now);
263+
store(mMonitorObjectStoreVector, now);
251264

252265
send(qualityObjects, ctx.outputs());
253266

@@ -360,11 +373,13 @@ QualityObjectsType CheckRunner::check()
360373
return allQOs;
361374
}
362375

363-
void CheckRunner::store(QualityObjectsType& qualityObjects)
376+
void CheckRunner::store(QualityObjectsType& qualityObjects, long validFrom)
364377
{
365378
ILOG(Debug, Devel) << "Storing " << qualityObjects.size() << " QualityObjects" << ENDM;
366379
try {
367380
for (auto& qo : qualityObjects) {
381+
qo->setActivity(*mActivity);
382+
qo->getActivity().mValidity.setMin(validFrom);
368383
mDatabase->storeQO(qo);
369384
mTotalNumberQOStored++;
370385
mNumberQOStored++;
@@ -374,11 +389,13 @@ void CheckRunner::store(QualityObjectsType& qualityObjects)
374389
}
375390
}
376391

377-
void CheckRunner::store(std::vector<std::shared_ptr<MonitorObject>>& monitorObjects)
392+
void CheckRunner::store(std::vector<std::shared_ptr<MonitorObject>>& monitorObjects, long validFrom)
378393
{
379394
ILOG(Debug, Devel) << "Storing " << monitorObjects.size() << " MonitorObjects" << ENDM;
380395
try {
381396
for (auto& mo : monitorObjects) {
397+
mo->setActivity(*mActivity);
398+
mo->getActivity().mValidity.setMin(validFrom);
382399
mDatabase->storeMO(mo);
383400
mTotalNumberMOStored++;
384401
mNumberMOStored++;

0 commit comments

Comments
 (0)